Iot Digital Thermometer Using Lm35 And Nodemcu
About the project
Here we will make a web server to display the temperature using LM35 as a temperature sensor.
Estimated time: 1 hour
Items used in this project
LM35 sensor is an analog linear temperature sensor. Its output is equivalent to the temperature. LM35 is an analog sensor so we have to change this analog output to the digital output. For this here we use the ADC pin of NodeMCU which is described as A0. We will attach the output of LM35 to A0.
We have 3.3 V as output voltage on NodeMCU’s pins. So, we will utilize 3.3V as Vcc for LM35.
HTML Code to display Temperature on WebPage
We are now going to display temperature on a separate webpage so that we can easily access from anywhere with the help of the internet.
HTML Code is as shown below:
WiFiClient client = server.available();client.println("HTTP/1.1 200 OK");client.println("Content-Type: text/html");client.println("Connection: close"); // the connection will be closed after completion of the responseclient.println("Refresh: 10"); // update the page after 10 secclient.println();client.println("<!DOCTYPE HTML>");client.println("<html>");client.print("<p ><span ><strong>Digital Thermometer</strong></span></p>");client.print("<p ><span ><strong >Temperature (*C)= ");client.println(temp_celsius);client.print("<p ><span ><strong >Temperature (F) = ");client.println(temp_fahrenheit);client.print("</p>");client.println("</html>");delay(5000);}
After uploading the code, open the serial monitor and hold the Reset button on NodeMCU. Now the board is connected to the Wi-Fi network which you have specified in your code and also you got the IP.
Copy and paste this IP in any web browser. Make assure that your system on which you are running the web browser should be connected to the same network. Then the temperature will be restored automatically in a web browser after every 10 Sec.