Spark Core Plant Monitor

Introduction: Spark Core Plant Monitor

About: Focussing currently on supplying open source software to the masses. I supply linux CDs and DVDs across Europe, as well as mirror various open source projects. Currently I mirror http://rsync.…

Using a Spark Core to monitor water level and tweet the current level


We have a plant that constantly suffers a localised drought – being quiet means that it tends to get ignored and ends up dry on a regular basis.

Out of necessity I have trained my plant to shout when it needs help, or more precisely before it needs help.

Hopefully it can survive 2015 :)

Link to plant current status:

Step 1: Requirements



Spark Core

5x 2.2KΩ resistors

1x 10KΩ resistor

3x 1 metre lengths of wire (red, black, green)

Soldering iron



Account with Spark

Account with

Step 2: The Circuit Images

This section shows the circuit I am using.

Any queries at all please do not hesitate to ask in the comments.

Step 3: The Circuit

The way we are going to monitor the water level is by passing a small voltage through the resistors and measuring the resistance. This will change depending on whether each resistor is wet or not giving us a number of values that we can then map to water levels. During testing we can determine these values and know when to send alerts.

The circuit:

Solder the red wire to one end of the 10KΩ resistor

Solder the green wire and one end of one of the 2.2KΩ resistors to the other end of the 10KΩ resistor

Solder all the remaining 2.2KΩ resistors to the free end of the 2.2KΩ resistor in a long chain.

Ensure that there is about 1 centimetre of solder and leg between each resistor as this will be where the water will be touching.

Finally, solder the black wire to the free end of the last 2.2KΩ resistor.

Take the black wire and run it back from the last resistor along all the other resistors as shown below:


The red wire goes to pin D6 of the Spark Core

The black wire goes to the GND pin of the Spark Core

The green wire goes to pin A0 of the Spark Core

Step 4: Getting Initial Figures


Connect your core to the Spark Core app and install the Tinder firmware.

full instructions are at

To read the probe, place the probe in the empty glass and press the D6 button in the app to turn the current on and read the value from pin A0, then finally press D6 again to turn off the current.

Write down the value given as “dry”.

Add a little water, enough to cover the first resistor and repeat the above steps, marking this value as “damp”.

Continue adding water to the height of each resistor in turn and taking values.

Stop before the top resistor (the 10k one).

Write the values as: dry, damp, moist, wet, soaking.

You will use these values in your version of the software.

Step 5: Creating Your App

Start the Spark IDE and log in.

If you do not have a bar on the left hand side of this page labelled “Spark apps” click on the < > button on the left hand side which will open it.

Click on “Create new app”

Give it a title such as “water monitor”

Click on the Libraries icon on at the bottom left of the window, below the "< >" icon.

Type in "httpclient" and click on the library. Click on "Include in app", select your app and click "Add to this app".

The code is attached to this page, copy and paste it into your sketch window, replacing the existing contents.

Finally, change the line

char APIKEY[] = "????????????????"; //thingspeak API key

with your own API key from the next step.

Step 6: Creating an Account With

Go to and create a new account.

When you have an account, click on "New channel".

Give it a name, something slightly more original than channel 12345. I chose "Water monitor".

You can fill in any information you wish here but it is entirely optional.

Change the title for field 1 (currently "Field label 1") to something more descriptive. I chose "Water level".

Click "Save channel".

Click on the Api Keys tab and make a note of your Write API key. Do not give this out, it gives unrestricted access to that channel.

Insert the API key into the Spark Core code as described in the previous step.

Step 7: Verify Your Code Works and Flash the Core

We can now verify that the code works and if so write it to the Spark Core.

Go back to the Spark tab and click on the second icon on the left hand side of the page (a circle with a tick in it). This is the verify button and will compile the code to ensure all is well.

The bottom line of the screen should now say "Code verified! Great work." which means that your code is working as intended. If so, click the top icon (the lightning bolt) and this will upload the code to your Spark Core.

If you get an error message, examine the error and see if you can find the fault. If you're stuck, leave a comment with the contents of the error message and I will try and determine the problem for you.

Step 8: Tweet When the Level Is in the Danger Zones

We will modify the code slightly now to send tweets when the water level changes to a danger zone.

Go to the Thingspeak tab and click on "Apps". In the new page that opens, click on "ThingTweet".

Click on "Link Twitter account".

In the next page, click "Authorize app"

Click on "Back to ThingTweet"

You will now be on a page with an API key. This is a different API key than the one earlier, and is used to update Twitter.

Attached to this page is the new code.

Be sure to insert your API key and Twitter API key into the code before flashing.

Indoor Gardening Contest

Participated in the
Indoor Gardening Contest

Be the First to Share


    • Anything Goes Contest

      Anything Goes Contest