Skip to content

Latest commit

 

History

History
65 lines (34 loc) · 3.96 KB

File metadata and controls

65 lines (34 loc) · 3.96 KB

Pot Monitoring WiFi device

This is the standard device for your Pot Pourri setup. It's a NodeMCU with sensors that can communicate via WiFi. It publishes sensor readings in defined intervals to a MQTT topic.

Hardware

Breadboard schema of the Pot Monitoring WiFi device

The humidity sensor is connected via an analog/digital converter module that outputs values [0..1024], while 0 is "absolutely wet" and 1024 is "absolutely dry".

Right now this is the only sensor in the setup, but it is possible to add sensors for other kinds of environment data via the same module.

Prerequisites

In order to be able to compile this sketch, you need to install the following packages via Arduino IDE's Package Manager:

Config

You need to configure this Sketch before you upload it to the NodeMCU. As the configuration contains sensitive data, it is not part of the sketch, but in a separate config.h.

This module comes with a config.template.h. Duplicate that file and rename it to config.h. Then change the values according to your setting.

You need to provide at least:

DEVICE_ID, which needs to be unique in your Pot Pourri setup.

WIFI_SSID and WIFI_SECRET as well as MQTT_SERVER.

All other values can stay untouched if you have deployed Pot Pourri with the default settings.

SAMPLING_INTERVAL doesn't need to be changed, but the default value of 60 ("send a value once every 60 seconds") is quite low. I encourage you to change it according to your needs. Aspects to keep in mind when choosing the value are accuracy of data over time, rate of change in real environment, currentness of data, amount of data to be stored, energy consumption of the device, interference caused by number of devices in WiFi at the same time, ...

Upload the Sketch

Before you upload the sketch, you need to remove the jumper cable that connects the pins "RST" and "D0". It is colored blue in the breadboard diagram above.

If you haven't used NodeMCU boards before, you need to install it via Tools > Board Manager first. The package name is esp8266 by ESP8266 Community.

Then select NodeMCU 1.0 (ESP-12E Module) in the Tools menu and upload the sketch to your board.

Don't forget to put the cable between pins "RST" and "D0" back in place. Without it, the NodeMCU can't wake up from Deep Sleep!

Usage

As you power up the device, it will automatically connect to your wifi, collect the current value and send it over MQTT. Then it will go to Deep Sleep mode for the defined SAMPLING_INTERVAL.

Troubleshooting

You can connect the device to your computer via USB and can use the Serial Monitor in the Arduino IDE in order to see the debug output.

Other options for troubleshooting are:

Wifi Connectivity

To see if the device is connected to your WiFi, you can look into your Router and see if it is in the list. If you have many devices, this will be difficult as they have very similar names. So the best way is to check the list before you power it up for the first time and again a couple of seconds after to see if a new device was added.

MQTT Connectivity

I have a project called robotrain that uses a similar tech stack. It comes with the tool mqtt-sniffer that can log messages from MQTT topics to the terminal.

The Pot Pourri device sends values via potpourri/devices/<device-id>/sensors/#.