The Covid – 19 lockdown made me think of new ways to entertain and engage my boys aged 6 and 8. With a room full of plants, there’s a question that popped up in my youngest’s mind, why are we giving same amount of water to all the different plants? What if one plant needs more and another needs less than what we give? If the thirst is real, we need to keep them happy and hydrated. We needed a system in place to check the moisture content before we water the plants and keep us motivated to do our chores with interest.
I used CircuitPython, the Mu code editor, the light sensor on Circuit Playground Express board, the capacitive touch pads on Circuit Playground Express, a nail and an alligator clip.
The hardware you’ll need for this project is the Circuit Playground Express, an alligator clip and a nail. You’ll also need at least two soil samples, one wet and one dry, for calibrating the code.
Assembly is as simple as connecting one end of your alligator clip to pad A1 on the Circuit Playground Express, and the other end of your alligator clip to the top of your nail.
Import few libraries and few lines of python code to Save the python code as code.py on your Circuit Playground Express board, using the Mu editor.
The code you need will look like this:
Once all done, place your nail into your dry soil sample.
When you run the code, you will see the touch.raw_value being printed to the output of the code editor.
As you can see, the dry value we are getting back is a little bit different than the default number. So let’s change
DRY_VALUE to reflect our results.
Now we’ll do the same to get our wet value.
Place the nail into your wet soil sample.
Now look at the values in the serial output. Our wet value is a little bit different, so let’s change
WET_VALUE as well.
We’ve determined our wet and dry values. Now we’ll use these values to make the LEDs green when the soil is 100% wet, and red when the soil is dry, or 0% wet. This is how you’ll know your plant needs to be watered!
Python Code : https://github.com/lsarikonda/CircuitPython/blob/master/Soil_Moisture.py