ESP8266 and DS18B20 – wireless ThingSpeak sensor

Here is another small project of mine: battery operated ESP8266 ESP-01 WiFi thermometer using DS18B20 and ThingSpeak API to collect data.

Before we proceed, you should:

esp8266 ds18b20 thingspeak sensor

Required hardware list:

  • ESP8266 ESP-01
  • DS18B20 digital thermometer
  • 2 AA batteries and a holder. I’m using 3D printed from this design
  • 4.7kOhm resistor
  • some wires and universal PCB. I’m using 50x70mm

Electrical diagram is pretty simple and it takes only few minutes to solder everything into place. Please remember about deep sleep hack. It is required!

esp8266 ESP-01 DS18b20 connection

esp8266 universal PCB

Code is also pretty straight forward: connect to WiFi, read temerature from DS18B20, sent temperature to ThingSpeak, go to sleep for 15 minutes, reboot and start again.

The only “mysterious” line of code is ESP.eraseConfig();. By default it is commented out and if everything is working, leave it like this. I have one ESP module that fails to change WiFi network if this line is not in place. I do not fully understand why it solves the problem, but it solves it. Maybe somebody more experience could throw some light on it?

Results can be seen here.

At this moment I have 2 wireless sensors connected to my heating system to monitor when it is working. More is on the way.

15 thoughts to “ESP8266 and DS18B20 – wireless ThingSpeak sensor”

  1. Hi. Nice project 🙂 Wanted to ask that is there any open source iot platform what I can run on my own server and save data on that? Is this code ok for that also?


    1. Probably there is one, never really dug deeply this topic. Yes, this code can be used if platform accepts GET (or POST after code change) requests

          1. Mine are working with String, maybe different library versions or something. I have no idea about version of my ESP8266.

  2. hello friend i have any question to you, how you compile your program??
    with arduino UNO or USB to TTL? if with arduino IDE what board to use for compile data?

  3. Nie wiem czy chcesz mieć tu komenty w języku ojczystym.
    Program wydaje się dość prosty ale coś mi nie bangla. Tzn przesyła do ThingSpeak ale czasami w odstępie 20sek zamiast 5min i przez te 20sek jest cały czas wybudzony. Zmieniłem tylko czasy, wifi i api. Wiesz dlaczego może tak robić?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.