This project uses Microsoft MakeCode for the code to read the soil sensor.
If you are new to Microsoft MakeCode, Adafruit has an excellent getting started tutorial at https://learn.adafruit.com/makecode.
The following is a short program that takes a moisture value we read as dry and gives a red neopixel reading if the reading falls below this dry amount.
Your MakeCode screen should have the following MakeCode program loaded.
The value read by the Circuit Playground Express is set to a level that might be a good dry soil value
1500. This number can be adjusted to give a better accuracy.
Ensure you have your plant monitor hooked up as done on the Build page.
Click on the console output and see what reading is being printed out.
Click on the Show console Device button and look at the output values. With the moisture monitor hooked up, the reading should be somewhat greater than about
890 or so with no alligator clip,
2160 for an alligator clip and 3 inch nail,
2600 in my dry(ish) pot with plant, You can set it lower, the Adafruit crew has
1500 for dry soil. Your numbers may vary. Be sure you have your Circuit Playground Express away from your body and on a dry, non-conductive surface like a countertop and keep your hands away while making settings to ensure things are not biased by the surroundings.
If your soil is dry, then the number you have with everything hooked up and no lights, should be good for your dry soil baseline. The larger the number, the wetter the soil. Note the number you are reading.
Change the value of the variable
dry_value in the
on start block to the value while the pot is dry and the lights are not on. You can then add water to the pot which will make the number go up and the light will go off when the project detects the soil is reading >
dry_value. It may take a few tries to dial in the number perfect for your plant. This will be your dry soil benchmark.
Any time the Circuit Playground Express reads a value the value that is the dry value or lower, it will turn all the lights red, alerting you. If the read value is greater than
dry_value, the NeoPixels will be turned off via the
Readings are taken every two seconds (2000 milliseconds) per the
pause block on the bottom. If you want to increase the idle time between readings, add additional
pause blocks. If you'd like a very long time between readings, see the trick at the bottom of the Going Further page.
Once you have your code "dialed in" with the final
dry_value, you can download the final code via Microsoft MakeCode to the Circuit Playground Express.
Place fresh AA batteries into your battery pack.
You may now unplug the USB cable to your computer and plug in the battery pack into the black battery jack on the Circuit Playground Express. The green On light should be glowing next to the USB jack letting you know you have power.
Set your plant in its final location. Place the Circuit Playground Express so you will notice the color of the NeoPixels as you walk by and the battery pack tucked away.
Go ahead and water your plant. The NeoPixels should be unlit. If they are still red, you'll need to go back and check your
You're now set to have your Circuit Playground Express monitor your plant moisture!