[No.14] Never Miss Watering with a Moisture Warning Panel!

Do you like growing plants? Plants like cactuses only need water once in a while, so it's easy to think "I'll do it later"... and then forget until the plant dries out. If the plant could tell you "Time for some water, please!", you'd feel too bad to forget... Is there a way to make that happen? This is the perfect time to invent something with SPACEBLOCK! Let's build a device that reminds you to water by showing a face when the soil gets too dry. You'll use the "soil moisture sensor module."

What You Need & Getting Ready
- SPACEBLOCK Standard Package [SPACEBLOCK board, USB cable, battery box]
- Soil moisture sensor module (soil moisture sensor)
- 8×8 RGB LED matrix panel (LED panel)
- Jumper wires [3 pin header–pin socket wires]
- A computer for programming

Connect the Expansion Parts to SPACEBLOCK

Check the next picture for the details. Make sure you know where to plug in the 3 jumper wires coming from the "G," "V" and "S" pins of the soil moisture sensor.

What Is a Soil Moisture Sensor?
A soil moisture sensor can measure how much water is in the soil.With no water the value is 0, and the more water there is, the bigger the number gets. Sending an amount or size to a program as a number like this is called analog input.
The soil moisture sensor raises or lowers the voltage on the pin it's plugged into on SPACEBLOCK, depending on how much water it measures. That voltage is turned into a number from 0 to 1023 and passed to the program.

Check the Soil Moisture Sensor Values

When you run the program, the value measured by the soil moisture sensor appears in the console.When the silver sensor part isn't touching anything, the value is "0." But even just pinching it with your fingers makes it detect moisture, and the number goes up. Try pinching it with a wet tissue and see how the number changes.

Be careful not to get water on anything except the silver part of the soil moisture sensor. Keep water away from the SPACEBLOCK board and the wires, too.Water can cause damage or even a fire. Wrap insulating tape around any part that might get wet so you can use it safely. Vinyl tape works, but butyl rubber tape, which is also very waterproof, sticks to itself instead of using glue, so it's easy and handy to use.

Change the LED Panel Display Depending on How Dry the Soil Is!
Now that you know how to use the soil moisture sensor, let's build a warning system with the LED panel.
Create a variable
Create a new variable and name it "water."


Split the program by conditions
Next, make the program that switches the LED display. We'll show a gentle warning when the soil starts to dry, and a strong warning when it's very dry. To decide which values should trigger the warnings, actually stick the soil moisture sensor into a flowerpot and check how much the number changes with the condition of the soil.

Here are some reference values.
[Reference values]
- 0–300: dry soil
- 300–700: damp soil
- 700–950: in water
This time, we'll show the first warning when the soil moisture sensor value goes below 500, and the second warning when it goes below 300. As shown in the next picture, use the [if ( ) then … else …] block and the [(0) (=) (0)] block to show the LED panel in 3 different ways depending on the value.

Choose what the LED panel shows
Add LED panel blocks inside the [if ( ) then … else …] block, and the program is finished as shown in the next picture.The plan is to show faces on the LED panel so you feel for your plant!

The program is done
That's it! Now a warning appears depending on how dry the soil is!
When the soil is moist enough, nothing happens...


A red "I can't take it anymore!!" face appears. The plant has reached its limit! Water, quick!!!

Now you'll never forget to water again!!