ESP8266 based MQTT sensor node, to sample I2C sensors and send them to a MQTT host.
This simple project turns an ESP8266 WiFi chipset running MicroPython into a simple sensor node, periodically sampling one or more sensors and sending the data to a MQTT broker (e.g. Mosquitto).
I use several of these nodes around my house to monitor various environmental parameters (temperature, humidity, etc.) which is then passed to my server running the HomeAssistant home automation software.
You will need to have a Python 3.x installed on the host system. The following
Python libraries are required, and will be installed by running make setup
:
adafruit-ampy
esptool
Tested on Windows, however this should work on other platforms too (since the flashing tools are all Python based).
An ESP8266 board is required - I'm using a NodeMCU clone board, since they're absurdly cheap on eBay. Any module with at least 1MB of flash should be fine.
You will need to connect one or more sensors to the board, typically via I2C.
See the src/sensors/
directory for supported sensors.
Working and stable, although I've only included a few sensor drivers. Patches welcome.
Connect your sensors to your board, and connect your board to the PC via a serial port (NodeMCU modules include a USB-to-Serial bridge IC).
COM5
with the path to themake bootstrap COM_PORT=COM5
You will need to reset the board once MicroPython is installed - this is usually just a case of pressing the board's RESET button, or shorting a RST pin to GND..
Copy the existing src/config.default.py
to src/config.py
, and edit it to
suit your own setup (documentation on the configuration format is included in
the default config file).
Install the application and configuration onto the module:
make flash COM_PORT=COM5
You can reflash the application only - the initial bootstrapping to install MicroPython is once off unless you are flashing a newer MicroPython release.
Released into the public domain - this builds on so much community work and it's so simple anything else would be a virtual crime.