This sketch reads several environmental sensors (e.g. humidity+thermometer or light meter), interrupts etc. and sends the data to an MQTT broker to be saved into a database or shown in some visualizations.
The software should run in any ESP8266 board, we've used Wemos D1 mini and mini Pro V1 and V2 lately.
First you must create settings.h with correct credentials:
cp settings-example.h settings.h
Then open settings.h
and check that these defines have meaningful values:
AP_PREFIX
and BURK_ID
are used to generate hotspot name for WiFi configuration page.
BURK_ID
is also sent with sensor data to the broker/server, so you have better control
of Demosensor instance's indentity.
In order to complile Demosensor code you have to install so many libraries,
which are listed in the beginning of Demosensor.ino
.
Carefully verify library name and version, if it is mentioned when installing.
If you know better way installing Arduino libraries than using Arduino IDE's awful library manager, let us know!
Connect your ESP8266 to your PC's USB port, check that correct USB port is defined in Arduino IDE, open Serial Monitor and then hit the Upload button. If everyting works as expected, ESP8266 gets flashed and you should see some text rolling in Serial Monitor window.
Demosensor uses WLAN (WiFi) connection to send the data it gathers to an internet cloud server. When switched on, it tries to find pre-defined WLAN.
If it can’t find it, Demosensor will create own WLAN hotspot called AP_PREFIX_BURK_ID,
those strings are defined in settings.h
. Use your PC, smart phone or tablet to connect this network.
If connection is successful (sometimes you have to switch off and on your WLAN several times until connection works), a popup window (a captive portal) or similar will open. First click Configure WiFi button:
And then in next window select desired WLAN by clicking it in the list and then set password in the lower form field. Double check that password is correct. You can write it down in clear text and then copy-paste it into the form.
Preferred protocol is MQTT, but it requires an MQTT broker service running on some server, so for initial testing there is HTTP POST option available.
Data format for both protocols is same.
TODO: add examples