WiFi Temperature Sensor with NodeMCU/ESP8266
With all the buzz around ESP8266 chips, I decided it was time to give it a go. If you are not familiar with ESP8266 chips, they are basically damn cheap (~ 3 €) WiFi chips that can also run your Arduino code.
I bought on eBay a NodeMCU and had it up and running in Arduino IDE in no time.
The project I’m talking about below is a DS18B20 sensor sending temperature data to a MQTT topic so that my home automation system (Jeedom with the MQTT plugin) can display it.
Here is below a breadboard view of the project:
Nothing fancy if you are used to OneWire devices: the resistor is a 4.7KΩ one.
The only wire which needs explanation is the blue one, running from D0
to RST
pins. This is done in order to allow the
NodeMCU to wake up from deep sleep.
The Arduino sketch below establishes Wifi connection, MQTT connection (to a Mosquitto broker), requests DS18B20 temperature, sends it to a MQTT topic then enters deep sleep for 30 seconds (the whole process starts again 30 seconds later):
Here is a screenshot from sensor’s history in my home automation system (I had my finger on the DS18B20 sensor at the beginning):
Some few things worth noting: battery powered nodes based on ESP8266 are really going to be a challenge. Doing so with a NodeMCU devkit does not make much sense as the devkit embeds way to many components drawing way too much current. I have ordered a bunch of ESP-12E modules and will try to do the same project this time without NodeMCU.