ESP32/ESP8266 Thermostat Web Server – Control Output Based on Temperature

In this project, you’ll build an ESP32 / ESP8266 Thermostat Web Server with an input field to set a temperature threshold value. This allows you to automatically control an output based on the current temperature reading. The output will be set to on if the temperature is above or set to off if it’s below the threshold – this can be used to build a simple thermostat project.

ESP32 or ESP8266 Control Output Based on Temperature Threshold build a Thermostat Web Server

As an example, we’ll read the temperature using a DS18B20 temperature sensor. You can use any other temperature sensor like DHT11/DHT22, BME280 or LM35.

To better understand how this project works, we recommend reading these tutorials:

Project Overview

The following image shows a high-level overview of the project we’ll build.

ESP32 ESP8266 Web Server with Temperature Threshold Value Project Overview
  • The ESP32/ESP8266 hosts a web server that shows the latest temperature readings from a DS18B20 temperature sensor.
  • There’s an input field to set up a temperature threshold value. When the temperature goes above the threshold, an output will be automatically turned on. You can invert this logic depending on your project application.
  • When the temperature goes below the threshold, the output will be turned off.
  • The system can be activated or deactivated through the web server. If you choose to deactivate the system, the output will keep its state, no matter the temperature value.

The following image shows how the web server page looks like.

ESP32/ESP8266 Temperature Web Server with Threshold for Automatic Output Control

Prerequisites

Make sure you check each of the following prerequisites before proceeding with this project.

1. ESP32 or ESP8266 Add-on Arduino IDE

This project is compatible with both the ESP32 and ESP8266 boards. We’ll program these boards using Arduino IDE, so make sure you have the necessary add-ons installed:

2. Async Web Server Libraries

To build the asynchronous web server, you need to install these libraries.

These libraries aren’t available to install through the Arduino Library Manager, so you need to copy the library files to the Arduino Installation Libraries folder. Alternatively, in your Arduino IDE, you can go to Sketch Include Library > Add .zip Library and select the libraries you’ve just downloaded.

3. Parts Required

ESP32 vs ESP8266 Development Boards

To follow this tutorial you need the following parts:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Schematic Diagram

Before proceeding, wire the DS18B20 temperature sensor to your board.

ESP32 with DS18B20 and LED

If you’re using an ESP32, wire the DS18B20 temperature sensor as shown in the following schematic diagram, with the data pin connected to GPIO 4.

Wiring Schematic diagram with DS18B20 temperature sensor connected to ESP32 board

ESP8266 with DS18B20 and LED

If you’re using an ESP8266, wire the DS18B20 temperature sensor as shown in the following schematic diagram, with the data pin connected to GPIO 4 (D2).

Wiring Schematic diagram with DS18B20 temperature sensor connected to ESP8266 board (NodeMCU)

Code – Thermostat Web Server with Threshold Input

Copy the following code to your Arduino IDE, but don’t upload it yet. You need to make some changes to make it work for you. You need to insert your network credentials and your default threshold value.

/*********
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp32-esp8266-thermostat-web-server/
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files.
  
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
*********/

#ifdef ESP32
  #include <WiFi.h>
  #include <AsyncTCP.h>
#else
  #include <ESP8266WiFi.h>
  #include <ESPAsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// REPLACE WITH YOUR NETWORK CREDENTIALS
const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";

// Default Threshold Temperature Value
String inputMessage = "25.0";
String lastTemperature;
String enableArmChecked = "checked";
String inputMessage2 = "true";

// HTML web page to handle 2 input fields (threshold_input, enable_arm_input)
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html><head>
  <title>Temperature Threshold Output Control</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  </head><body>
  <h2>DS18B20 Temperature</h2> 
  <h3>%TEMPERATURE% &deg;C</h3>
  <h2>ESP Arm Trigger</h2>
  <form action="/get">
    Temperature Threshold <input type="number" step="0.1" name="threshold_input" value="%THRESHOLD%" required><br>
    Arm Trigger <input type="checkbox" name="enable_arm_input" value="true" %ENABLE_ARM_INPUT%><br><br>
    <input type="submit" value="Submit">
  </form>
</body></html>)rawliteral";

void notFound(AsyncWebServerRequest *request) {
  request->send(404, "text/plain", "Not found");
}

AsyncWebServer server(80);

// Replaces placeholder with DS18B20 values
String processor(const String& var){
  //Serial.println(var);
  if(var == "TEMPERATURE"){
    return lastTemperature;
  }
  else if(var == "THRESHOLD"){
    return inputMessage;
  }
  else if(var == "ENABLE_ARM_INPUT"){
    return enableArmChecked;
  }
  return String();
}

// Flag variable to keep track if triggers was activated or not
bool triggerActive = false;

const char* PARAM_INPUT_1 = "threshold_input";
const char* PARAM_INPUT_2 = "enable_arm_input";

// Interval between sensor readings. Learn more about ESP32 timers: https://RandomNerdTutorials.com/esp32-pir-motion-sensor-interrupts-timers/
unsigned long previousMillis = 0;     
const long interval = 5000;    

// GPIO where the output is connected to
const int output = 2;

// GPIO where the DS18B20 is connected to
const int oneWireBus = 4;     
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);
// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("WiFi Failed!");
    return;
  }
  Serial.println();
  Serial.print("ESP IP Address: http://");
  Serial.println(WiFi.localIP());
  
  pinMode(output, OUTPUT);
  digitalWrite(output, LOW);
  
  // Start the DS18B20 sensor
  sensors.begin();
  
  // Send web page to client
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/html", index_html, processor);
  });

  // Receive an HTTP GET request at <ESP_IP>/get?threshold_input=<inputMessage>&enable_arm_input=<inputMessage2>
  server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
    // GET threshold_input value on <ESP_IP>/get?threshold_input=<inputMessage>
    if (request->hasParam(PARAM_INPUT_1)) {
      inputMessage = request->getParam(PARAM_INPUT_1)->value();
      // GET enable_arm_input value on <ESP_IP>/get?enable_arm_input=<inputMessage2>
      if (request->hasParam(PARAM_INPUT_2)) {
        inputMessage2 = request->getParam(PARAM_INPUT_2)->value();
        enableArmChecked = "checked";
      }
      else {
        inputMessage2 = "false";
        enableArmChecked = "";
      }
    }
    Serial.println(inputMessage);
    Serial.println(inputMessage2);
    request->send(200, "text/html", "HTTP GET request sent to your ESP.<br><a href=\"/\">Return to Home Page</a>");
  });
  server.onNotFound(notFound);
  server.begin();
}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    sensors.requestTemperatures();
    // Temperature in Celsius degrees 
    float temperature = sensors.getTempCByIndex(0);
    Serial.print(temperature);
    Serial.println(" *C");
    
    // Temperature in Fahrenheit degrees
    /*float temperature = sensors.getTempFByIndex(0);
    Serial.print(temperature);
    Serial.println(" *F");*/
    
    lastTemperature = String(temperature);
    
    // Check if temperature is above threshold and if it needs to trigger output
    if(temperature > inputMessage.toFloat() && inputMessage2 == "true" && !triggerActive){
      String message = String("Temperature above threshold. Current temperature: ") + 
                            String(temperature) + String("C");
      Serial.println(message);
      triggerActive = true;
      digitalWrite(output, HIGH);
    }
    // Check if temperature is below threshold and if it needs to trigger output
    else if((temperature < inputMessage.toFloat()) && inputMessage2 == "true" && triggerActive) {
      String message = String("Temperature below threshold. Current temperature: ") + 
                            String(temperature) + String(" C");
      Serial.println(message);
      triggerActive = false;
      digitalWrite(output, LOW);
    }
  }
}

View raw code

How the Code Works

Continue reading to learn how the code works, or skip to the Demonstration section.

Libraries

Start by importing the required libraries. The WiFi (or ESP8266WiFi), AsyncTCP (or ESPAsyncTCP) and ESPAsyncWebServer are required to build the web server.

The OneWire and DallasTemperature are required to interface with the DS18B20.

The code automatically imports the right libraries accordingly to the selected board (ESP32 or ESP8266).

#ifdef ESP32
  #include <WiFi.h>
  #include <AsyncTCP.h>
#else
  #include <ESP8266WiFi.h>
  #include <ESPAsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

Network Credentials

Insert your network credentials in the following lines:

// REPLACE WITH YOUR NETWORK CREDENTIALS
const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";

Default Temperature Threshold Value

In the inputMessage variable insert your default temperature threshold value. We’re setting it to 25.0, but you can set it yo any other value.

String inputMessage = "25.0";

Auxiliar Variables

The lastTemperature variable will hold the latest temperature reading to be compared with the threshold value.

String lastTemperature;

The enableArmChecked variable will tell us whether the checkbox to automatically control the output is checked or not.

String enableArmChecked = "checked";

In case it’s checked, the value saved on the inputMessage2 should be set to true.

String inputMessage2 = "true";

HTML Text

Then, we have some basic HTML text to build a page with two input fields: a temperature threshold input field and a checkbox to enable or disable automatically controlling the output.

The web page also displays the latest temperature reading from the DS18B20 temperature sensor.

The following lines display the temperature:

<h2>DS18B20 Temperature</h2> 
<h3>%TEMPERATURE% &deg;C</h3>

The %TEMPERATURE% is a placeholder that will be replaced by the actual temperature value when the ESP32/ESP8266 serves the page.

Then, we have a form with two input fields and a “Submit” button. When the user types some data and clicks the “Submit” button, those values are sent to the ESP to update the variables.

<form action="/get">
  Temperature Threshold <input type="number" step="0.1" name="threshold_input" value="%THRESHOLD%" required><br>
  Arm Trigger <input type="checkbox" name="enable_arm_input" value="true" %ENABLE_ARM_INPUT%><br><br>
  <input type="submit" value="Submit">
</form>

The first input field is of type number and the second input field is a checkbox. To learn more about input fields, we recommend taking a look at following resources of the w3schools website:

The action attribute of the form specifies where to send the data inserted on the form after pressing submit. In this case, it makes an HTTP GET request to:

/get?threshold_input=value&enable_arm_input=value

The value refers to the text you enter in each of the input fields. To learn more about handling input fields with the ESP32/ESP8266, read: Input Data on HTML Form ESP32/ESP8266 Web Server using Arduino IDE.

processor()

The processor() function replaces all placeholders in the HTML text with the actual values.

  • %TEMPERATURE% » lastTemperature
  • %THRESHOLD% » inputMessage
String processor(const String& var){
  //Serial.println(var);
  if(var == "TEMPERATURE"){
    return lastTemperature;
  }
  else if(var == "THRESHOLD"){
    return inputMessage;
  }
  else if(var == "ENABLE_ARM_INPUT"){
    return enableArmChecked;
  }
  return String();
}

Input Field Parameters

The following variables will be used to check whether we’ve received an HTTP GET request from those input fields and save the values into variables accordingly.

const char* PARAM_INPUT_1 = "threshold_input";
const char* PARAM_INPUT_2 = "enable_arm_input";

Interval Between Readings

Every 5000 milliseconds (5 seconds), we’ll get a new temperature reading from the DS18B20 temperature sensor and compare it with the threshold value. To keep track of the time, we use timers.

Change the interval variable if you want to change the time between each sensor reading.

unsigned long previousMillis = 0;
const long interval = 5000;

GPIO Output

In this example, we’ll control GPIO 2. This GPIO is connected to the ESP32 and ESP8266 built-in LED, so it allows us to easily check if the project is working as expected. You can control any other output and for many applications you’ll want to control a relay module.

// GPIO where the output is connected to
const int output = 2;

DS18B20 Temperature Sensor Init

Initialize the DS18B20 temperature sensor.

// GPIO where the DS18B20 is connected to
const int oneWireBus = 4;
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);
// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);

To learn more about interfacing the DS18B20 temperature sensor with the ESP board, read:

setup()

In the setup(), connect to Wi-Fi in station mode and print the ESP IP address:

Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
  Serial.println("WiFi Failed!");
  return;
}
Serial.println();
Serial.print("ESP IP Address: http://");
Serial.println(WiFi.localIP());

Set GPIO 2 as an output and set it to LOW when the ESP first starts.

pinMode(output, OUTPUT);
digitalWrite(output, LOW);

Initialize the DS18B20 temperature sensor:

sensors.begin();

Handle Web Server

Then, define what happens when the ESP32 or ESP8266 receives HTTP requests. When we get a request on the root / url, send the HTML text with the processor (so that the placeholders are replaced with the latest values).

server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
  request->send_P(200, "text/html", index_html, processor);
});

When, a form is submitted, the ESP receives a request on the following URL:

<ESP_IP>/get?threshold_input=<inputMessage>&enable_arm_input=<inputMessage2>

So, we check whether the request contains input parameters, and save those parameters into variables:

server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
  // GET threshold_input value on <ESP_IP>/get?threshold_input=<inputMessage>
  if (request->hasParam(PARAM_INPUT_1)) {
    inputMessage = request->getParam(PARAM_INPUT_1)->value();
    // GET enable_arm_input value on <ESP_IP>/get?enable_arm_input=<inputMessage2>
    if (request->hasParam(PARAM_INPUT_2)) {
      inputMessage2 = request->getParam(PARAM_INPUT_2)->value();
      enableArmChecked = "checked";
    }
    else {
      inputMessage2 = "false";
      enableArmChecked = "";
    }
  }

This is the part of the code where the variables will be replaced with the values submitted on the form. The inputMessage variable saves the temperature threshold value and the inputMessage2 saves whether the checkbox is ticked or not (if we should control the GPIO or not).

After submitting the values on the form, it displays a new page saying the request was successfully sent to your board an with a link to return to the homepage.

request->send(200, "text/html", "HTTP GET request sent to your ESP.<br><a href=\"/\">Return to Home Page</a>");
});

Finally, start the server:

server.begin();

loop()

In the loop(), we use timers to get new temperature readings every 5 seconds.

unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
  previousMillis = currentMillis;
  sensors.requestTemperatures();
  // Temperature in Celsius degrees 
  float temperature = sensors.getTempCByIndex(0);
  Serial.print(temperature);
  Serial.println(" *C");
    
  // Temperature in Fahrenheit degrees
  /*float temperature = sensors.getTempFByIndex(0);
  Serial.print(temperature);
  Serial.println(" *F");*/
  
  lastTemperature = String(temperature);

After getting a new temperature reading, we check whether it is above or below the threshold and turn the output on or off accordingly.

In this example, we set the output state to HIGH, if all these conditions are met:

  • The current temperature is above the threshold;
  • Automatic output control is enabled (the checkbox is ticked on the web page);
  • If the output hasn’t been triggered yet.
// Check if temperature is above threshold and if it needs to trigger output
if(temperature > inputMessage.toFloat() && inputMessage2 == "true" && !triggerActive){
  String message = String("Temperature above threshold. Current temperature: ") 
                   + String(temperature) + String("C");
  Serial.println(message);
  triggerActive = true;
  digitalWrite(output, HIGH);
}

Then, if the temperature goes below the threshold, set the output to LOW.

else if((temperature < inputMessage.toFloat()) && inputMessage2 == "true" && triggerActive) {
  String message = String("Temperature below threshold. Current temperature: ") 
                   + String(temperature) + String(" C");
  Serial.println(message);
  triggerActive = false;
  digitalWrite(output, LOW);
}

Depending on your application, you may want to change the output to LOW, when the temperature is above the threshold and to HIGH when the output is below the threshold.

Demonstration – ESP Thermostat

Upload the code to your ESP board (with the DS18B20 wired to your ESP32 or ESP8266 board).

Open the Serial Monitor at a baud rate of 115200 and press the on-board RST/EN button. The ESP will print its IP address and it will start displaying new temperature values every 5 seconds.

ESP32 ESP8266 Temperature threshold Arduino IDE Serial Monitor

Open a browser and type the ESP IP address. A similar web page should load with the default values (defined in your code):

ESP32 ESP8266 Temperature threshold trigger web server Arduino IDE

If the arm trigger is enabled (checkbox ticked) and if the temperature goes above the threshold, the LED should turn on (output is set to HIGH).

ESP32 ESP8266 Control Output when Temperature is above threshold web server

After that, if the temperature goes below the threshold, the output will turn off.

ESP32 ESP8266 Control Output when Temperature is below threshold web server

You can use the web page input fields to change the threshold value or to arm and disarm controlling the output. For any change to take effect, you just need to press the “Submit” button.

At the same time, you should get the new input fields in the Serial Monitor.

ESP32 ESP8266 Change temperature threshold on web server

Wrapping Up

In this project you’ve learn how to create a web server with a threshold value to automatically control an output accordingly to the current temperature reading thermostat web server). As an example, we’ve controlled an LED. For real world applications, you’ll probably want to control a relay module. You can read the following guides to learn how to control a relay with the ESP:

We’ve used raw HTML text, to make the project easier to follow. We suggest adding some CSS to style your web page to make it look nicer. You may also want to add email notifications to this project.

If you want to learn more about the ESP32 and ESP8266, try our projects and resources:

Thanks for reading.


Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »


Enjoyed this project? Stay updated by subscribing our weekly newsletter!

32 thoughts on “ESP32/ESP8266 Thermostat Web Server – Control Output Based on Temperature”

  1. Been looking for something like this for awhile. Can we expand the project to include cooling. I live in a part of the world where cooling is needed especially in the summer months.

    Reply
  2. This is a very nice project. I can imagine replacing my old therostats with these IoT enabled devices.
    One thing puzzles me however: I’d like to tuck the device into an installation socket (caja de conexión) but how do I power the whole thing? Using a USB Power Suppy (wall wart) or a battery in not really an option.
    I would love to have an instruction on how to make a super miniature 230V power suppy which is part of the assemby and can provide the energy for an ESPxxx board (3.3V or 5V and 300mA).
    Keep on with the exellent work!
    Chris

    Reply
    • On Ebay you can buy very small 240 VAC to 3.3V DC converters. See below:
      ebay.co.uk/itm/AC-to-DC-220V-3-3V-Step-Down-Buck-Voltage-Regulator-Power-Supply-Module/331938666556?hash=item4d4916183c:g:~5MAAOSwopRYalBK

      This one is a bit expensive. I found some costing between £ 1-2 each including
      shipping to Norway. Search on Ebay. Good luck.

      Reply
  3. I have a similar project that is a DHT22 hooked up to an arduino board that powers a relay switch to turn a plug in outlet on and off. Bit of a side note if you’re using something like this along side a relay to power an outlet. Relays really don’t last very long if you check them every five seconds. Mine ran for about 5 months before giving out until I changed the interval to 60 seconds. Given, my relay was a fairly cheap one i got off Wish but still.
    I’m probably going to do this project when I get the time and I might even use it to replace my current setup since it’s so robust.

    Reply
  4. If you are using a relay to control a furnace or air-conditioner, normally you want to have 2 setpoints, a min-max temperature range, e.g. for a furnace a turn-on minimum temperature, and higher maximum turn-off temperature. (For cooling it’s reversed.)

    Limiting the time interval is one approach, but HVAC equipment runs inefficiently if turned on and off in short intervals.

    A programmable offset could be used, e.g. .5 degC or 1 degF so a 20.5 setting would have a turn-on at 20.0 and turn off at 21.0. In the loop, the prior on/off state would need to be saved (or else read the GPIO), then used to add or subtract an offset.

    If you are logging, and rounding to 1degF or .5degC, then you also might want to add some hysteresis to the rounding. If the temperature is 20.25, the rounded value might flip between 20.0 and 20.5. If you record the prior rounded value and the new temperature is increasing, then add .25 to the recorded temperature before rounding. If decreasing, subtract .25 to the temperature.

    Reply
    • Hi Carl.
      You are absolutely right!
      The aim of this project was to show how to add a threshold to your web servers. But for cooling/heating, having an interval is a better option.
      You can modify the web server to include two input fields for the interval.
      Thanks for sharing that information.
      Regards,
      Sara

      Reply
  5. Rui,

    This is great work. I have been attempting to build a temperature controller for some time. Thanks, you have saved me a lot of time.

    Best regards
    Phil

    Reply
  6. Great project, I have a wood stove off site from my house (car barn), I would like to monitor water jacket temperature, currently it has a 3” analog glass faced thermometer sticking out of it.
    It would be great if I could get information from the water jacket to my home and iPhone, this project appears that it could do this. I have seen several projects similar to this one but the one caveat that always stops me or stumps me is how to convert code from C to F . I know a formula that states temp /9 then * 5 + 32 or / 5 * 9 -32 but none of this helps me when converting from C to F . Celcius always seams to be the default values in these projects. It would be nice to see how to convert to F . Thanks, your projects are great.

    Reply
    • Hi Larry.
      Our code shows how to convert to F.
      You just need to comment the following lines as follows:
      // Temperature in Celsius degrees
      // float temperature = sensors.getTempCByIndex(0);
      // Serial.print(temperature);
      // Serial.println(” *C”);

      And uncomment these ones
      // Temperature in Fahrenheit degrees
      float temperature = sensors.getTempFByIndex(0);
      Serial.print(temperature);
      Serial.println(” *F”);

      Basically, you use the getTempFByIndex() function instead of the getTempCByIndex() function.
      I hope this helps.
      Regards,
      Sara

      Reply
  7. Very nice these examples!
    question: the first line is #ifdef ESP32
    shouldn’t there also be a line #define ESP32; or #define ESP8266;
    Regards, Jan.

    Reply
  8. hello

    could you please show us how to password protect the webserver ?
    What lines to include in the code?
    So we can use this themostat to control home heating without worry that someone else can play with our temperatures?

    thank you

    Reply
  9. Tutorial looks great, well laid out but I keep getting -127, I am up north but don’t think it is that cold. Have tried replacing parts, checking twice but not getting anywhere. Help would be appreciated.

    Reply
    • Hi Don.
      That usually happens when there’s something wrong with the sensor or with the wiring.
      Without more information, it is very difficult to find out what might be wrong.
      Regards,
      Sara

      Reply
  10. Absolutely agree – these are great tutorials.
    I do have a question please… if the ESP32 restarts (or is restarted), then does the threshold temp revert to its initial setting (the default value in the code)? Should I store the updated threshold value in SPIFFS or is there a better way of holding it ‘persistently’?
    Many thanks, Malcolm

    Reply
    • Hi.
      In this particular example the value is not permanently saved. When it is restarted, it goes back to the default value.
      You can save the value in SPIFFS, for example, and read it every time the ESP32 restarts.
      To easily save a value, you can use the EEPROM library. For example, see this tutorial: https://randomnerdtutorials.com/esp32-flash-memory/
      I hope this helps.
      Regards,
      Sara

      Reply
  11. Hi Sara

    Lovely Project. I have one question:
    I tried this and it works great, but I need to keep refreshing the web page to update the temperature value.
    Is this normal and is it possible to have it update automatically without refreshing?

    Thank you

    Reply
  12. Hey, loved the project and have been trying to use it. But I’ve been having a problem. If the device is fresh started everything works well, but after some time (ESP8266) it shows -127 degrees and it stops working! Could you please help me figure out what’s wrong? And why does it go to this state? If restarted it starts working again.

    Best Regards,
    João Graça

    Reply
    • Hi.
      The -127 means that the sensor was not able to get a valid reading.
      You can add something in your code that checks if the reading is valid. And if not, you can either try to get another reading, or reset the ESP8266 via software.
      I hope this helps.
      Regards,
      Sara

      Reply
  13. Hi Sara,
    The DS18B20 are addressable Temp Sensors.
    In the current program is it possible to add 2 more sensors and read them vis the web server

    I really enjoy your courses and articles

    Thanks
    Kevin

    Reply

Leave a Reply to Egon Cancel reply

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.