Programming an ESP32 HiGrow sensor module for

Plant Monitoring

Published: 19th March 2023; Last updated: 19th March 2023

Preface

A few weeks ago, I received a Pilea plant as a gift. While I could indeed need some leafy fellow in my flat, I feared it would share the same fate as its predecessor, which was a Sansevieria "Laurentii" that died from overwatering. To prevent myself from drowning my plant (again), I bought an all-in-one sensor module to monitor my plant. The plan was to receive a notification on my phone whenever the soil gets too dry, so I would only water my Pilea when it's necessary.

In case you read this article with the intention to implement your own plant monitor, you should take a look at the conclusion before buying the hardware, as there are some caveats with the HiGrow sensor module I used.

The HiGrow Sensor Module

The HiGrow Sensor Module

HiGrow Sensor Module with DHT11 sensor, ESP32 MCU and capacitive soil moisture sensor.
I added some sticks near the soil moisture sensor for mounting the HiGrow in an upside down position.

Since I am not very skilled at soldering, I bought an all-in-one sensor module on AliExpress named "HiGrow". The board's full name is "ESP32 DHT11 WIFI Bluetooth Soil Temperature Humidity Sensor18650". It is a board that consists of an ESP32 microcontroller that has WiFi and Bluetooth capabilities, a DHT11 humidity and temperature sensor and a soil moisture sensor. On the backside of the board, there is also a mount for a 18650 battery.

Board Specs

Board name: WeMos Wifi & Bluetooth Battery
Chip: ESP32-D0WDQ6 (revision 1)
Crystal: 40MHz
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse

Battery Specs

Type: 18650 Li-Ion
Voltage: 3.7 V
Capacity: 3000 mAh

I did not buy the rechargable battery at AliExpress, but decided to get a CE-certified one at a German electronics retail store.

Programming the ESP32

For programming the HiGrow board you will need Arduino IDE v2 and some USB serial drivers. In the Arduino IDE, select the ESP32 board named WeMos WiFi&Bluetooth Battery and choose the default Baud rate of 115200.
Detailed instructions and download links for the serial USB drivers can be found in the Readme on GitHub. You will also find the code for the ESP32 there. If you like this blog post, let me know by leaving a ★ star on the repository.

Water Me!

The ESP32 controller will wake from deep sleep every 12 hours, read the sensor data and send it to a small web server via HTTPS in JSON format:

{
  "timestamp": "2023-01-26T15:40:54",
  "humidityInPercent": 55,
  "temperatureInCelsius": 21,
  "perceivedTemperatureInCelsius": 20.59146118,
  "soilMoistureInPercent": 14
}
I decided against a MQTT broker, since I currently only have this single sensor module and only one consumer for the data. Currently, the plant sensor is identified by the URL path to which it sends the POST request (/pilea/1). If I ever plan to monitor more than one plant, this should be changed, so the sensor module is not "hardwired" to this specific plant. Instead, the sensor should get an ID and the server should map the ID to the plant which the sensor is currently monitoring. The server is configured to send a notification to my smartphone, if the soil moisture level falls below a given threshold. I will only water my plant when I receive such a notification. If I forget to water it, the soil moisture will still be below the defined threshold and I will receive another notification.

Conclusion

While my plant monitor project generally works, I would not recommend the HiGrow sensor module "for production use". The HiGrow module has a few issues: First of all, it has a high power consumption. Even when it is in deep sleep and wakes only twice a day, the battery usually lasts for no longer than 5 days. As my Pilea requires watering every 7-14 days, I would have to charge the module's battery more often than actually watering the plant. As it is not possible to monitor the battery level directly from the board, I would only notice after a while that it stopped sending data. This won't work out on the long run.

I tried to find a solution on the internet, but only found postings where others described a similar high power consumption. One person who measured/analyzed it, assumes that there is a general issue with the board's power management. Powering the board via the USB connector would be a workaround. However, as the Pilea is in my living room, I would prefer a more aesthetic solution (I do not want to have ugly wires connected to my plant).

Besides the power consumption issue, I had the feeling, that the soil moisture sensor's accuracy is rather poor.
For reliably monitoring my Pilea, better hardware is needed.

I will consider replacing the HiGrow module by single components (i.e. an ESP32 MCU, a soil moisture sensor, a DHT11 or DHT22 sensor and a battery pack), wire them up and hide them in a 3D printed case. The adjustments in the code should not cause a lot of effort (probably only some pins need to be changed).

Pilea plant with sensor, growing in an upside down flower pot Pilea plant with sensor, close-up
The Pilea is growing in an upside down flower pot.
Since it is also called "UFO plant", I found it looks more appropriate this way.

Credits

For implementing my project, I took some inspiration from a blog post by Stefan Fambach. In his blog post Stefan also lists some 3D printer blue prints for a case.


To the top