Close

IoT plant

The idea for my first IoT / Particle’s Photon project was simple: Plants don’t last long in our household. What if the plant tweeted at me when it needed watering?

Idea

The idea came from two solid facts:

  • plants don’t get a lot of love in our household
  • I spend a lot of time on Twitter

The logical solution was a plant that could tweet at me.

I used a Phantom YoYo High Sensitivity Moisture Sensor and a Particle Photon.

When the moisture in the soil gets too low, the Photon fires a tweet and blinks its LED (D7).

It might take me a while to react and water the plant. As a result:

  1. The threshold should be set so the plant wouldn’t die on me if I don’t water it for another 8 hours (on a workday, for example).
  2. The Photon should only tweet me once, and not every time the loop runs and the moisture sensor’s value is below the threshold.

I decided to store the act of tweeting in a variable to check against before tweeting again.

The system would then have three possible states:

  1. Soil is moist—OK
  2. Soil is too dry and tweet must be sent
  3. Soil is too dry, tweet was sent, LED is blinking

So it looked like an if, else if, and else kind of thing.

Process

I loved integrating the hardware, software, and webhook dimensions of this small project. Here are a few details.

Getting a Twitter account for the plant

Fairly simple. I rely on plus addressing in Gmail to create new Twitter accounts, though. This way all my notifications get in my Gmail inbox.

I also created a new Google account to get a Google Voice phone number to tie to my new Twitter account (the number redirect calls to my personal phone and I can receive verification calls).

See the tweets
Webhooks allow you to send data from your connected device anywhere on the Internet
Tweeting from the Photon

I relied on the generic Webhook integration to use ThingSpeak‘s ThingTweet app. I granted access to the Twitter account to ThingSpeak and got a ThingTweet API key.

A Webhook integration meant that I could use the Particle.publish() function built in the Photon while relying on their cloud.

Getting to know the sensor

I had to understand the range of values the sensor was returning. I started with testing it submerged in water, which should return the highest conductivity.

I then used the Arduino’s serial to read values at different levels of soil moisture. This was necessary to set a threshold to fire up a tweet.

Coding

I started building in Arduino before transferring and finalizing my code in the Particle desktop IDE (Atom-based).

I was able to use the LowPower.h library for Arduino but couldn’t find an equivalent for the Photon. That led to an issue that I’ve discussed further below.

View the code on GitHub

Results and challenges

The IoT plant worked great but I ran into a couple of issues.

Sensor erosion

The product specs state that the moisture sensor “uses Immersion Gold which protects the nickel from oxidation.”

Well, there’s not a lot of it, then! I quickly noticed a drop in performance (I wasn’t getting any tweets when the plant obviously needed water).

This is an issue I read about and I was able to implement a low power library when I was starting on an Arduino Uno: I only ran some current through the sensor a couple of times a day.

I wasn’t able to find a similar library for the Photon and it led to the sensor’s erosion.

Phantom Yoyo sensor in the plant's soil, Arduino Uno in the background.
Sensor location

I’m not really sure how location—or height—of the sensor impacts the moisture reading.

I was anxious to set up my Photon but looking back, I should’ve spent more time getting serial readings from different positions.

Improvements

If I were to spend more time on this project, I would:

  • design a 3D printed case. I’d have to research what kind of gaskets are suitable for prototyping plastics.
  • do a bit more research on the low power libraries available for the Photon.
  • maybe look into a way to provide power through a solar panel, so the system could be installed on plants that are nowhere near a power outlet (while still within wifi range).
  • use an Electron (cellular) instead and not rely on wifi at all.