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.

5 thoughts on “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?

    Thanks,
    Jarno

    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.

Leave a Reply

Your email address will not be published.