Measuring temperature is one of the most common technique used because it is important for many operations and tasks to be performed like in any industries where heaters are used, heat up to a certain temperature is required. When it comes to sensing temperature, a temperature sensor is used that is installed at a place whose temperature is to be sensed. The temperature of that place can be monitored through internet using internet of things.
Monitoring is employed in various applications,including temperature, pressure, flow rate, capacity, acceleration, and so on. According to the quantities, distribution and detected frequency of the monitored objects, there are different monitoring methods to acquire the measurements. Several problems usually occur during the monitoring process of the temperature in a room. For example, a server room must be kept between 15 to 20 degree Celsius to monitor a temperature in or else the server might crash and can cause a loss of hundreds thousands. Management has to choose either to place a person to monitor the temperature, or to save on human capital by developing a system that can monitor the temperature from other places at any given time.
In order to solve the problem, the web-based temperature monitoring system that can be access anywhere and anytime through the Internet is build. With this system a user can remotely monitor the room temperature from anywhere which could save the human expenses. IoT WebBased Temperature Monitoring is one type of temperature recorder that monitors a temperature in a room and stores the data into a database and display the current temperature on the website through a web server. The system will continuously monitor the temperature condition of the room and the data can be monitored at anytime and anywhere from the Internet. The temperature monitoring is widely used in various processes like in automotive industries, air conditioning, power plant and other industries that need the data to be saved and analyzed. The main purpose of this system model is to make it easy for the user to view the current temperature.
Circuit Design
ESP8266 is used as main hardware for Temperature Monitoring system, We can connect Temperature sensor LM35 directly to the ESP8266, It gives 10mV per degree centigrade.
ESP8266 IoT Based Temperature Monitoring Code
Program consists of two parts index.h header file which contains our HTML web page and main code
index.h
const char MAIN_page[] PROGMEM = R"=====( <!DOCTYPE html> <html> <head> <meta http-equiv="refresh" content="3”> <title>Temperature Monitoring Web Server</title> <style> div.card { width: 250px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); text-align: center; border-radius: 5px; background-color: #F5F7A0 } div.header { background-color: #E03C3C; color: white; padding: 10px; font-size: 40px; border-radius: 5px; } div.container { padding: 4px; } </style> </head> <body> <center><h2>Temperature Monitoring Web Server</h2> <div class="card"> <div class="header"> <h1>@@temp@@ °C</h1> </div> <div class="container"> <h2>Temperature</h2> </div> </div> <a href="https://circuits4you.com">Visit Us: Circuits4you.com</a> </center> </body> </html> )=====";
Main ESP8266 Arduino IDE Code
/* * Temperature Monitoring Web Server Connects to your Router * circuits4you.com */ #include <ESP8266WiFi.h> #include <WiFiClient.h> #include <ESP8266WebServer.h> #include "index.h" //Web page //SSID and Password of your WiFi router const char* ssid = "Your_SSID"; const char* password = "Your_password"; ESP8266WebServer server(80); //Server on port 80 //=============================================================== // This rutine is exicuted when you open its IP in browser //=============================================================== void handleRoot() { String s = MAIN_page; int Temperature; Temperature = analogRead(A0); //Read Analog Voltage of ADC Pin Temperature = Temperature/10; //10mV is 1 degree C //Convert Temperature int to String then Replace @@temp@@ in HTML with temperaure value s.replace("@@temp@@",String(Temperature)); server.send(200, "text/html", s); //Send webpage to browser } //=============================================================== // SETUP //=============================================================== void setup(void){ Serial.begin(9600); WiFi.begin(ssid, password); //Connect to your WiFi router Serial.println(""); // Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } //If connection successful show IP address in serial monitor Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); //IP address of ESP server.on("/", handleRoot); //handle root location server.begin(); //Start server Serial.println("HTTP server started"); } //=============================================================== // LOOP //=============================================================== void loop(void){ server.handleClient(); //Handle client requests }
Results
Get IP address of ESP8266 from serial monitor, connect your laptop or phone to same WiFi network and open web browser enter IP address you will see Temperature readings in web page.
Can you please tell me how to refresh the temperature? It only reads the first value.
how to include index.h header file in program? it shows error as compilation terminated… when i remove the header ‘MAIN_page’ is not declared in this scope..
Hi
You need to paste the HTML code into the NotePad++ and save as .h after that paste the index.h in to the arduino cod folder.