I have attempted to grow food in the past, but I quickly realized that I’m way too forgetful. Everything eventually died, and my dreams were crushed. Then, as any programmer would, I figured I could hack around my laziness. Here is the story of how I digitized my green thumb.
Using the same materials and code from the Losant Moisture Sensor Kit, I can successfully grow green onions at home. But this time, I'll receive a text message if the moisture level drops too low. There is even have a live dashboard to see how my onions are doing when I'm away.
Nature is no match for my technology.
To get started, I picked green onions. I cook with them a ton and they are super easy to grow. They can even grow directly in water. Here is what you would need:
- Pot/Jar/Container - Since this is low-maintenance planting, any container should do. I reused an old ice cream container.
- Green onion bulbs - Get some green onions from any store and save the bulbs after you use them.
- Soil - I just used organic soil from Amazon.
Then, put the soil in the container and push the green onion bulbs into the soil. In the beginning, the final product looked like this:
I know what you’re thinking: “How did he kill his green onions even though it is so easy?” Yes, I know. It’s pretty sad. That’s why blog post even exists. But, now that we have onions in the works let's monitor them.
The Losant Moisture Kit has all the hardware you need for this project. Here is the complete list:
- 1 NodeMcu with ESP8266 WiFi microcontroller
- 1 moisture sensor
- 3 male-to-female jumper wires
- 1 solderless breadboard
- 1 USB cable
Because of the Losant Moisture Sensor Kit, the full instructions to setup wire, and flash the device are in the documentation. However, here is the most important piece:
The kit also comes with an LED that gives you the ability to turn the LED on and off based on the moisture. It's very helpful for an in-person visual representation of the moisture level.
Every minute, the NodeMCU turns on the sensor, reads the moisture level, reports the moisture to Losant, and then turn off the sensor. The power cycling is to protect from corrosion. Water and Electricity are not the best of friends. Once in Losant, we can do something with this moisture data.
Every time we get a moisture level, we need to check the moisture level. If it's below a certain level, I'll need a text to remind me to water my onions. In Losant we can build a workflow and use the Latch node for this purpose.
In this workflow, we capture the payload. If it's below the “badLevel,” let's shoot me an email and text. Determining what's "bad" depends on a bunch of factors. After looking at the data and seeing how dry the soil is, you'll get a good grasp on a good and bad level.
The Latch node will only take the successful condition once until reset. So, in this case, we only want one text, not one text every minute. Using the Latch node, we will only get a text once, unless the moisture level goes above our "goodLevel" to reset the latch.
We have nothing on for the negative case of the Latch node because we do not have to do anything when all is well.
Let It Grow
After about two weeks, your onions should look like this:
Also, because of the workflow, you should also get alerts when you need to water the plant.
After data had started to populate in Losant, I thought it would be interesting to see a dashboard of a status and trends of my plant's moisture levels. It would also come in handy when I have more than one plant to manage. After I put together an indicator block and some time series graphs, Voilà:
You can also see a live version of this dashboard.
Now that we’ve mastered nature, there is so much more to do. The next obvious thing to do is to add more plants. We could even set up a system to automagically water the plants. The sky...or the ground is the limit.
Did I miss anything? Feedback? If so, let me know. I would love to hear your thoughts.