About Project
LM35 Temperature Sensor
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
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 response
client.println("Refresh: 10"); // update the page after 10 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("<p style='text-align: center;'><span style='font-size: x-large;'><strong>Digital Thermometer</strong></span></p>");
client.print("<p style='text-align: center;'><span style='color: #0000ff;'><strong style='font-size: large;'>Temperature (*C)= ");
client.println(temp_celsius);
client.print("<p style='text-align: center;'><span style='color: #0000ff;'><strong style='font-size: large;'>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.