flower pot

flower pot

In this example we program a humidity sensor with the Calliope mini

Easy

30 mins

from 8 years on

Story

Who is the project for? For children, teenagers and adults who do not have a green thumb. :-)

1Ingredients You need
  • Calliope Mini
  • Two small cables or wires with or without clip connectors
  • Two paperclips
  • Flowerpot (or cup, glass,...)
  • Water
2Measuring humidity with electric current.

With the Calliope you can measure super moisture of earth. Water conducts electricity. That's why even wet earth conducts electricity. Dry earth does not. The wetter the earth is, the more electricity comes through. If the earth is only slightly damp, very little current flows.

3Measuring electricity with the Calliope Mini

The Calliope Mini has connections from which electricity flows. The corner labeled +, for example. And the Calliope can measure current. For example, the corner labeled 1.

For the computer, electricity is what voice is for humans. We talk with sounds, computers talk with electricity. And with electricity there are two languages: One is to use electricity to give signals. Similar to the flashlight. So ON and OFF.

This is called digital communication. The other way you can talk to the computer is when you turn the voltage up and down. The voltage of electricity is like the pressure with which water comes out of the tap. For example, by turning the voltage up and down, you can make lamps brighter and darker. This language is called analogue.

And with [analog read pin P1] the Calliope can check how high the voltage of the connected current is at P1.

Did you know?

Computers can count up to 1023 with 10 fingers.
Computers calculate 1 and 0. But why? Well, you think you can only count to 10 with your FIngern?
Wrong! You can count to 1023 with 10 fingers. And that goes like this. The first finger is the 1. Each further finger twice as much as the right neighbour.
So: 1 2 4 8 16 | 32 64 128 256 512. For a 9 the finger 1 (pinkie finger) and the finger 8 (index finger) are up. 15 you count with an 8, a 4, a 2 and a 1.

And because a computer remembers numbers with switches, you can remember much more with this binary way of counting with fewer switches. Would be bad if we needed 1023 fingers to count to 1023. Now you know why computers are binary (dual system), i.e. calculate with 1 and 0 and not in the decimal system as we humans do.

Did you know: 3, 3 Volts are 1023

The Calliope Mini can supply a current with a voltage of 3, 3 volts on pins. The Calliope Mini has a converter with which it can measure voltage (analog signal) and translate it into digital computer language. The analog digital converter has 10 bits with which it can count. Like our ten fingers. So 0 Volt is also 0. And 3.3 volts is 1023, the highest number that can be calculated with 10 bits (fingers). If the A/D converter displays 511 (about half of 1023), then it has a voltage of about 1.5 volts (half of 3.3 volts). Now you know why the Calliope Mini with the block "analog read pin" displays anything between 0 and 1023.

4How to build the flower pot
The ends with the paperclips come into the soil
  1. Connect one of the two cables to corner 1 (pin 1) and the other to corner 0 (pin 0) of your Calliope mini. By threading the wire strand through the hole and wrapping it. With clip connectors, if your cable has any, or with some adhesive tape stick the wire strands on it.

  2. Put paper clips at the end of each cable. So that a lot of metal touches the soil.

  3. Now insert both cable ends with the paperclips into the ground. Nice and far apart.

5The programming

In this example we use the MakeCode popup: yes editor.

This is what we want to program now:

  1. On pin 2 we want to turn on the current. You can find that in the menu Pins under Advanced: [digital write pin P0 to 1]. As you learned above, digital values are current that is on or off. And write to 1 means switching on. 1 means on, 0 means off. If the earth in the pot is damp, electricity now flows through the pot. Don't worry, it won't hurt the plant. The current is much too low for that.

  2. Now we want to measure with pin 1, how much current arrives through the soil from one paper clip to the other. This works with [analog read pin P1]. You can display the result with [show number], that you can find under basics.

6At what value is the earth too dry?
Good question. You have to try that. Do a test with dry soil and drip water on it until you think the dampness is good. Then measure with the Calliope.

Now you can take a [If Then Else] block from Logic. Let's assume you measured 500. If the humidity, i.e. the analog value [analog read pin P1] is greater than 500, then show a laughing smiley. Otherwise show a crying smiley.

Now you understand the final code.

7The final code
That's what it looks like when everything's hooked up. Leave some space between the paperclips in the soil. Don't let them touch each other.

This text as well as the images are published under a CC BY 4.0 DE license popup: yes. It was originally published in German popup: yes by Boris Crismancich popup: yes and translated into English by the Calliope team.

YOU CAN FIND THE FINISHED FILE BELOW.

The program can be opened directly with the MakeCode editor.

hex