How to Give Your Plant a Voice

Using the Internet of Things to develop an agricultural solution

Emily Deneen
4 min readJan 2, 2021
My plant is happy and healthy!

INTRO

Are you really bad at gardening? Do you forget about other living things in your house, especially if they don’t make noise? Are your plants having a generally bad time? This is the project for you! Now introducing the plant sensor that screams at you when you don’t give your plant water!

Houseplants are easy to forget about, especially when you’re sidetracked by watching youtube videos about blue polka-dotted frogs wearing hats. Instead of potentially forgetting about my plant, I decided to give her a voice! I used the Internet of Things to create a device that will send me a message every morning, telling me the moisture levels of the soil. I have this data interpreted to tell me when I need to give my plant more water. This is also far more accurate than just keeping a calendar, as the humidity levels fluctuate a lot according to the time of year and the location in the house.

The moisture sensor in the plant.

MATERIALS NEEDED

For this project, I used:

The microcontroller
The moisture sensor
The relay
Finished product

Software/languages Used:

  • PuTTY — terminal emulator used to view the serial console of the esp8266 and upload Lua code
  • Lua/NodeMCU — the “big brains” of the project and base firmware
  • Python — the “timekeeper”, “data interpreter”, and “message sender”
  • mosquitto — MQTT broker used to exchange messages
  • Telegram — the poor soul that has to deal with all of my messaging shenanigans

The Lua portion of this project does a few things, outlined below:

  • Connect to the configured WiFi network
  • Connect to the MQTT broker (mosquitto)
  • Wait for a command telling the device to read the ADC. There is a safety check to make sure that we are not currently busy processing another read command.
  • Enable the relay to power the moisture sensor
  • Wait five seconds for the reading to stabilize
  • Publish the results to the MQTT broker

You can see the code below:

And here’s the Python side. I started this project when my plant’s soil was dry, so by getting a reading from the moisture sensor, I was able to determine that the value of 400 or above would indicate that my plant needs water. Any other value lower than 400 would mean that my plant is sufficiently watered (for now). This code then takes the moisture sensor’s reading that was published to the MQTT broker, and sends an appropriate text message via a Telegram bot. When my plant gets dry, she gets quite overdramatic! Poor plant, bottling her needs inside for too long. 😔

Some text is censored in this image to protect the author’s personal information.

The Result

We now have a happy and healthy plant that tells us when she’s thirsty! :-)

Here’s a video outlining the process:

Next steps

  • Structure my code / message payload so that multiple sensors can be added and the Python code can identify the plant associated with the sensor.
  • Replace the telegram library with aiogram and use an asynchronous event loop.
  • Currently, the module is dependant on external power and must be plugged into an outlet. Future plans for another project include managing a battery power source for increased flexibility. I want to be able to move my plants around and not be tethered to an outlet! This would be a large change since maintaining an association with the access point will drain the battery quickly, so we can not rely on receiving a “read” command to take a reading.
  • Replace the relay with transistors. This would let me power the sensor without an audible click. I am not leaving the sensor powered at all times to avoid corrosion on the probe terminals. Without the relay click I could have the esp8266 deep sleep for several hours, wake up, take a reading, and then go back to sleep.
  • Development for an outdoor module might include a water pump solution to deliver water at the appropriate time — reducing water waste. Perhaps a solar-powered or wind-powered solution would work well for the outdoors. (of course, the module would need to be water proof)
  • Overall, this is a good first step in developing a cost-effective agricultural solution.

--

--

No responses yet