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:
- Know how to program ESP8266 with Arduino IDE
- Know how to run ESP8266 on battery power for months
- Have an account on ThinkSpeak, create a channel and obtain write API key
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!
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.
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
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
Thanks for your replay 🙂 What version of esp board files did you use? 2.3 or lower?
I’m new to 8266 so 🙂 I got the blink demo flashed and it works but with Wifi code I get error: http://pastebin.com/FYeFn9NK
Thanks.
Ok, got it working changed ssid and password from String to char* 🙂
Mine are working with String, maybe different library versions or something. I have no idea about version of my ESP8266.
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?
One of the first links in this post: https://quadmeup.com/programming-esp8266-with-arduino-ide/
@Dziku
it should help:
// WiFi.begin(wifiSSID, wifiPassword);
WiFi.begin(wifiSSID.c_str(), wifiPassword.c_str());
Why is it you write GPIO0 high?
there is a LED connected to it
additional LED?
at photos we see ESP01 witch have bulitin LED at GPIO2 where You connect DS
my mistake, of course GPIO1 is LED for ESP01, at GPIO2 is ESP01S
również korzystam z tego rozwiązania, fajna sprawa. Z tym że ja wrzucam dane z czujników do zabbixa. zasilam ogniwami 18650 dzięki czemu rok spokojnie pociągnie bez ładowania.
https://imgur.com/dtpKz6a.png
no to jest już luksus 😉 czy możesz się podzielić tym rozwiązaniem?
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ć?