« Build ideas: Smart plant alerts
What did you make using nio?
Using nio, I set up my desk plant (aka Keanu Leaves) to tweet me when it needs water. Using a Raspberry Pi 3 and a soil moisture sensor, nio sends a tweet mentioning me whenever it’s time to water my plant.
Beginner: 1 hrs
Experienced: 20 min
- Raspberry Pi 3 (or any device that can run nio)
- Twitter API and App
- ADC Chip
- Soil Moisture Sensor
- Jumper wires
- If breadboarding instead of using hat:
Want to start building with nio?
We are currently accepting applications for our early access program. Learn more below.
Kylie explaining how she got Keanu Leaves to tweet to her
Why would you use nio to create this project?
Even though I see Keanu Leaves on my desk every day, I sometimes forget to water him. Enabling him to notify me when he’s in need of more water using nio was a no-brainer -- it requires just two small services. Obtaining data from the sensor and setting thresholds to conclude when the plant is getting low on water and when it needs water was very simple with the help of nio. The most complicated logic necessary for this use case was formatting the tweet. In order to contextualize the tweet’s content, I had to know when the state of the system changed and what the previous state was.
The first service in this system, GetSoilMoisture, simply obtains data from the soil moisture sensor in the dirt. The IdentityIntervalSimulator sends a signal through the system every hour. This signal triggers the MCP300X block in the system to gather current data from the moisture sensor and publishes that data to a topic that other services can subscribe to. The reason behind keeping this service small is to make sure the nio system stays modular. By splitting up the services to accomplish one goal, it makes it easy to use this same soil moisture data for a different purpose in the future if necessary.
The second service, SendTweet, subscribes to the soil moisture data from the first service and uses information about the state of the system to create a Twitter message that the service will post. The logic that goes into this service is slightly more complicated than the first one. The first ConditionalModifier block configures the state of the system based on the value of the sensor data. The StateChange block will emit a signal whenever the soil moisture changes between the thresholds set in the previous ConditionalModifier block. This block emits a signal that has the current (new) state of the system and the previous state. Based on that logic, the second ConditionalModifier block configures the text of the tweet. The Filter block just before the tweet is posted makes sure the tweet has content and the PostTweet block posts the tweet to the account configured in the block properties.
Any advice you would want to give a person when recreating this project?
- Problem: Using the MCP block in nio requires SPI to be enabled on the Raspberry Pi -- enable SPI in the Raspberry Pi config.
- Enhancement: Have a reservoir of water with a spigot to enable automatic watering.
- Enhancement: Hook up Blink1 to visually see moisture in the soil.
The nio service was throwing an error as soon as signals were passed into the MCP300X block. The problem was that the Raspberry Pi needs SPI enabled in order for nio to read from the sensor using the MCP300X block. This interface can be enabled in the Raspberry Pi’s config.
To make this system even better, I would have liked to have added a couple of features and additional hardware pieces. First, I would create a reservoir of water so the plant could decide when it needs water and how much water to give itself. In addition, adding a Blink1 LED or some other sort of indicator to portray the state of the system would be helpful instead of just waiting for a tweet to be sent out. Both of these enhancements would have been fairly simple to add using nio.
Have questions on how to build it? Watch the step by step tutorial below:
Step by step tutorial
Don't know what to do next or need to troubleshoot? Follow along with Kylie as she walks you through her entire process.
Scaling nio to an enterprise-level adoption:
Although this is a great example of how to monitor plants in a home or office setting, imagine having a whole vineyard that can talk to you. While you probably wouldn't want thousands of vines sending tweets, nio enables the plants, weather, and other important variables to communicate directly with the irrigation system to autonomously deliver the perfect amount of resources at the optimal time. In fact, we've used the same nio platform to transform a manually-dependent, subjective farming operation into a highly-instrumented and automated example of precision agriculture at Deep Sky Vineyard in Willcox, AZ. With guidance from the farmer, nio acts in real-time given the complete context coming from the field. Whether that calls for turning on a pump, opening a valve, or just sending an alert to the farmer's phone, nio keeps the operations running smoothly, resources optimized, and crop potential maximized. Learn more about how we did it on our case study page!
Interested in partnering with niolabs?
We are in the process of building out our partner ecosystem. Visit our partner page and learn how we can help you deliver digital transformation.