I will share how to set up LM35 ESP8266 NodeMCU to get local area temperature using LM35 Temperature Sensor with ESP8266 NodeMCU Board.
We all use weather applications to know the current temperature. This requires the Internet. So if I say you can know your area temperature without the Internet, how it will be?
Components Used:(Click to Buy)
What is LM35 Temperature Sensor?
LM35 is an integrated analogue temperature sensor whose electrical output is proportional to Degree Centigrade. LM35 Sensor does not require any external calibration or trimming to provide typical accuracies.
It has 3 pins – two pins are 5V and Ground. The middle pin is Voltage out. We use the reading of this pin to determine the temperature using some arithmetic calculation.
How to Connect LM35 ESP8266
Following Connection Diagram you can see how to connect LM35 with ESP8266 NodeMCU.
Code Explain of LM35 ESP8266
We are here using Voltage in pin as we want 5 Volt input. SO we have calculated temperature by taking 5 Volt input to LM35. If you connect 3.3 Volt to LM35, then replace “500” in code with “330” in tempc variable calculation inside the code.
After calculating we are displaying the temperature in the serial monitor in both Celsius and Fahrenheit.
Arduino Sketch for LM35 ESP8266
const int sensor=A0; // Assigning analog pin A0 to variable 'sensor'
float tempc; //variable to store temperature in degree Celsius
float tempf; //variable to store temperature in Fahreinheit
float vout; //temporary variable to hold sensor reading
tempc=vout; // Storing value in Degree Celsius
tempf=(vout*1.8)+32; // Converting to Fahrenheit
Output LM35 ESP8266
So, here you can see the temperature is showing in the serial monitor of the Arduino IDE.
You can also watch this tutorial video in Hindi.