PIPER MAKE

EDUCATOR GUIDES


YOU ARE HERE

Energy expedition

Mission 2 of 3

Energy expedition: Mission 2 of 3

Soil Sensor


Beginner

1 hour

Grades 3 - 8

MISSION OBJECTIVE

Learn how to collect and display data using loops, actions, and variables.

Piperbot and Pip are excited to find sustainable farming operations on Mars! Let's build a Soil Sensor to measure how much water reaches the plants.

View student interface at make.playpiper.com
MISSION CHARACTERS

Piperbot

Pip
MISSION MATERIALS

Computer with USB port and Chrome or Edge browser
Piper Make Base Station or Starter Kit
Soil Sensor

MISSION RESOURCES

Learning Goals

  1. Students will practice breadboarding and wiring.
  2. Students will review and understand the computational concepts of:
    • Loops: Running the same sequence multiple times.
    • Sequence: Identifying a series of steps for a specific task.
  3. Students will demonstrate core computational thinking concepts, including algorithm design, by creating an ordered series of instructions for solving similar problems or doing a task, such as turning a light off and on in the correct order.
  4. Students will create programs that include events, loops, and conditionals.
  5. Students will practice organizing problems into smaller, manageable tasks.
  6. Students will test and debug a program or algorithm to ensure it accomplishes the intended task.
  7. Students will perform different roles when collaborating with peers during the program development's design, implementation, and review stages.

Learning Activities

The following sections will contain step by step instructions for ELA, ELD and Math extensions directly related to this mission. Adjust the directions to fit your ELA, ELD and Math standards.

ELA Extension: Write a Story

Ask students to write a narrative story from the point of view of the plant.

  • Have students explain how water helps a plant grow.
  • Ask them to explain how the sensor saved the plant's life.
  • Tell students to get creative and have fun with their characters!

Math Extension:

Ask students to use the reading in the Console to determine the average.

  • For older students, have them calculate the average.
  • Ask younger students to choose the number that looks closest to the average.

Career Connections

Natural Sciences Manager: Salary $144,440/yr
Agricultural Engineer: Salary $83,260/yr
Environmental Engineer: Salary $96,530/yr
Soil and Plant Scientist: Salary $65,730/yr

Hardware Diagram






Tutorial Steps

Soil Sensor

We're going to build a soil sensor!

This sensor will work by measuring how much, or how little, moisture there is in your soil. To do this, we will build a circuit board that connects to a plastic plant stake, with one end placed down into the soil.

If you don't have a houseplant for this tutorial, you can use a glass of water.

If you've already built the Air Guitar tutorial, the circuit in this activity will be similar.

You will need:
You will also need:
  • Plastic Plant Stake
  • Vinyl Rainbow Sticker
  • (2) Copper Tape Strips
  • A small cup you can fill with water
Click NEXT.

First, let's prepare our plant stake so that it can measure moisture.

Grab the copper foil strips. We're going to place them evenly apart down the center of the plant stake, using the image below as a guide.

Line up each foil strip just below where the top point begins to angle so that there is about 1/4 inch hanging over the flat edge.

Make sure that there is a gap between the foil strips, and make sure there is a gap all of the way around the foil strips except on the one edge they overhang.

When you are ready to stick the foil strips to the stake, peel off the paper backing to expose the adhesive side on the foil. Press the foil strips down, applying them as smoothly as possible.
Click NEXT.

Next, let's make it pretty!

Begin by folding the ends of both foil strips under so they adhere to the backside of the stake. Make sure that the two strips don't touch each other.
Now, attach the vinyl rainbow sticker to the front of the stake over the top of the copper foil strips. Don't forget to peel the sticker off of the paper before you stick it down!
The sticker needs to protect the foil strips from getting wet - so make sure there are no bubbles or wrinkles in the sticker. The sticker needs to be sealed to the stake all of the way around.

When your soil moisture sensor it ready, click NEXT.

Grab your Pico and Breadboard, as well as the bar graph LED. Attach the bar graph LED along the center of the Breadboard opposite the Pico. The center gap on your board should pass under the middle of your bar graph LED lengthwise.


The letters and numbers on the side of the bar graph LED should be on the side shown by the arrow below:
Next, we're going to connect the 330 Ohm Resistors to the bar graph LED. Connect 1 Resistor in line with each LED bar - you should have 10 total. Then connect the other end of each Resistor to the ground bar along the blue line on the outer edge of the Breadboard.

First, connect a M2M Jumper wire from a GROUND pin on the top of your Pico to the Ground row on the top of your Breadboard.

Now, we're going to connect the M2M Jumper wires. Connect 1 wire in line with each LED bar, opposite the 330 Ohm Resistors. It doesn't matter which color wires you use. Next, connect the other end of each wire to the GPIO pins of your Pico, beginning with GP15, then GP14, GP13, and so on until you've reached GP6. If you are having a hard time telling which pins of the Pico you should connect to, use the DIGITAL VIEW tab at the bottom of the screen for a helpful diagram!
We still have the 1 MOhm Resistor remaining. If you look carefully, the 1 MOhm Resistor has different color bands than the 330 ohm Resistors. The 1 MOhm Resistor's color bands are black-brown-green, and it has a much bigger resistance. in fact, "MOhm" means 1,000,000 ohms! That's way more than 330!

Attach the 1 MOhm Resistor to your Breadboard, connecting one end to GPIO pin 0 and the other to Ground.

Hang on - we're almost there!

Connect one alligator clip wire to the left wire of this 1 MOhm Resistor and the other to the right wire.

Finally, attach an alligator clip to each of the copper foil strips. Be sure it is pinched around and touching the foils.

You made it!
Click NEXT.

Because everyone doing this tutorial is building their own sensor - they will all be slightly different - and that's okay! It means that in order to take accurate measurements with our sensor, we have to calibrate it.

For this step, you will need the cup that you can fill with water. Start by making sure the cup is empty, and place your soil moisture sensor into the cup with the pointed end down.
Now that our sensor is in an empty cup, we need to write a program that will take a reading from our sensor to see what it's "Dry" value will be.

Grab a start block from the Chip menu and drag it onto the workspace. Next, grab a repeat forever block from the Loops menu and connect it to the start block. Then, place a print block from the Chip menu inside of the repeat forever block. Finally, remove the "_" from inside the print block and drag it to the trash can to delete it:
Click NEXT.

Grab a capacitive sense block from the Sensing menu and place it into the print block. Make sure it is set to pin 0:
Now, let's run this short program to get a reading from the sensor. Click the CONSOLE tab at the bottom of the screen to open it. Then, click CONNECT, and finally, click START.

You should begin seeing readings from your sensor:
1438
1410
1499
1422
1427
1483
1465
If you look carefully at the numbers above, they seem to average about 1450. Your sensor will probably be similar, but not exactly the same, and that's okay - figure out a number that seems like a good average for your sensor's readings and write that number down - this is your sensor's "Dry" reading.

Go ahead and click STOP, then click NEXT.

Now that we have our "Dry" reading, it's time to get our "Wet" reading. Carefully fill your cup with water up to the line on the sticker:
Run your program again to get the "wet" reading from your sensor. Click START.

You should begin seeing new readings from your sensor:
6120
6035
6107
6082
6046
6111
6058
If you look carefully at the numbers above, they seem to average about 6050. Your sensor will probably be similar, but not exactly the same, and that's okay - figure out a number that seems like a good average for your sensor's readings and write this new number down - this is your sensor's "Wet" reading.

Go ahead and click STOP, then click NEXT.

How does the soil moisture sensor work anyway? It uses a property of materials called capacitance. Capacitance is an object's ability to hold an electric charge.

When we connect the Pico to a piece of metal like one of the copper strips in side of the sensor, the Pico can charge the copper strip by raising it's voltage up to 3.3V. The Pico does this really fast, and it makes the copper strip positively charged:
If something like your hand, finger, or water is really close to the copper strip, it can hold more of a positive charge:
Next, the Pico tells the pin that sent the charge to stop sending and instead to become an input so that it can read the voltage of the copper strip:
The reason we use a really big Resistor is to prevent the charge from draining back to the ground pin too quickly. While the foil's positive charge is draining away, the Pico is taking measurements of the voltage. When the voltage drops down close to zero, it stops and takes note of how long it took to drain the charge:
If the positive charge drained away quickly, there wasn't something touching or very close to the sensor. If it drained away more slowly, something like your hand or water was close enough to the foil. That's how it can tell!

What's even crazier is that the whole measurement - from charging the foil to letting it drain away - only takes 0.005 seconds. That means the Pico can take 20 measurements in the same amount of time that it takes you to blink your eyelids once!
Click NEXT.

A big part of our circuit is the bar graph LED, so let's add some blocks that use it!

Grab a setup bar graph led block from the Actions menu and place it between the start block and the repeat forever block. Set the start pin to 15 and the end pin to 6:
Next, grab the bar graph led display block from the Actions menu and connect it below the print block. Grab the 1 block from inside the bar graph led display block and drag it to the trash can to delete it. Grab a map value block from the Logic menu and place it in the input of the bar graph led display block:
Click NEXT.

Grab the capacitive sense block from inside of the print block and drag it into the input of the bar graph led display block. Then, right click the print block and choose Delete Block:
Remember those numbers you wrote down? We need to enter them into the map value block. The first two numbers in the map value block are the "from range". We need to set these to the dry and wet measurements we took earlier (remember, your measurements might be a little different):
Next, we need to set the "to range". The bar graph led display block is expecting a value from 0 to 10, so let's set it to those values:
Set the dropdown on the bar graph led display block from only to up to. The "only" setting lights up 1 LED on the bar graph display at a time. The "up to" setting lights up all of the LEDs "up to" the value in the block:
Click NEXT.

Let's give our sensor a try while we still have our cup of water out. Click START.

Now, try slowly lifting the sensor out of the water to see how the bar graph LED changes.

Click STOP.

Wouldn't it be nice if your program made a sound or alarm when the water level was too low?

Click the Variable menu to open it and then click the Create variable button. Name your new variable "cycles". Grab the set cycles to block and connect it between the start block and the setup bar graph led block. Grab a 0 block from the Values menu and place it into the set cycles block:
If the water is too low, we want our computer to make an alarm sound, but we don't want the alarm sound to go off every 0.5 seconds, so we are going to use the cycles variable to space out how often the alarm sound happens.

Grab an if _ = _ do block from the Logic menu and connect it below the bar graph led display block. Right-click the capacitive sense block and select Duplicate. Place the new block into the left side of the _ = _ block. Then, grab a 0 block from the Values menu and place it into the right side of the _ = _ block. Change the = (equals) to a < (less than).

We want an alarm to go off when the soil is dry, so we need to pick a value that is a little bit higher than our dry value. Add 50 to your dry value and change the 0 in the _ < _ block to your dry value plus 50:
Let's make our alarm go off every 5 seconds. Since our repeat forever loop's wait time is 0.5 seconds, this means that we will need it to make 10 loops before it makes an alarm sound.

Grab another if _ = _ do block from the Logic menu and place it inside of the if do block that's already in your program. Next, grab a cycles block from the Variables menu and place it into the left side of the _ = _ block. Then, grab a 0 block from the Values menu and place it into the right side of the _ = _ block. Change the 0 to 10:
Click NEXT.

Let's pick a sound to play for our alarm. Grab a play sound block from the Sounds menu and place it into the new if do block. Then, grab any one of the sound blocks from the Sounds menu and place it into the play sound block's input:
Now, we need to add blocks that make the cycles variable count up when the water level is too low, and reset after an alarm sound is played.

Right-click the set cycles block at the top of your program and select Duplicate. Connect the new set cycles block right below the play sound block. Then, grab a change cycles by block and connect it below the if do block you just placed the set cycles block into:
That's it! Click START to try it out. Lift your sensor out of the water and wait a few seconds. After about 5 seconds, you should hear an alarm sound.

If you don't hear a sound, your Dry + 50 value is too low - try making it Dry + 100 and run your program again.

Once you are happy with your program, go ahead and click STOP. Feel free to try your sensor in a potted plant if you have one!

Click NEXT.

Click EXIT to return to the menu and start your next coding challenge.

Blueprint

OPEN IN BLUEPRINT VIEWER  DOWNLOAD

Have an different version? Look for more information on the Support Page.

Troubleshooting Tips


Our customer support specialists are on hand to ensure your implementation of Piper runs seamlessly.
View Support Docs or Contact Support
EXPANDED RESOURCES

Term Glossary


Fossil Fuels Sources of energy made from prehistoric plants and animals (coal, oil, natural gas). (CE)

Renewable Energy Energy sources from natural resources that can be more easily replenished (solar, water, nuclear). (CE)

Capacitance An object's ability to hold an electric charge.

Pollution Anything that dirties the Earth, such as litter, smoke from cars and factories, or water contamination. (CE)

View Full Glossary

Standards Alignment


Individual Standards
  • CA 3-5.CS.2 Demonstrate how computer hardware and software work together as a system to accomplish tasks.
  • CA 4-ESS3 Obtain and combine information to describe that energy and fuels are derived from natural resources and that their uses affect the environment (5.ESS3.C; MS.PS3.D; MS.ESS2.A; MS.ESS3.A; MS.ESS3.C; MS.ESS3.D