Soil Sensor – Piper

SOIL SENSOR

PIPER MAKE EDUCATOR RESOURCES SERIES

To do this project, you will need a Piper Make Starter Kit. Get yours here:

Build and code a tool that measures the moisture in soil.

To get started, head to Piper Make and hit this icon:

Time: 30 minutes

Age Range: 8+

Difficulty: Intermediate

Students will use a circuit similar to the one built in Air Guitar to create a soil sensor.

Note: There are step by step instructions for the students to follow in the tutorials included in each project on Piper Make. These provide directions both for writing code and for building the electronic circuits. The tutorials are well-defined and most students will be able to follow them with little assistance required.

LEARNING OBJECTIVES

Students will:

 

  • Practice breadboarding and wiring
  • Review and understand computational concepts of:
    • loops: running the same sequence multiple times.
    • sequence: identifying a series of steps for a task
  • Demonstrate computational thinking core concepts, including:
    • Algorithm Design by creating an ordered series of instructions for solving similar problems or for doing a task, such as turning a light off and on in the right order.
  • Create programs that include events, loops, and conditionals.
  • Decompose problems into smaller, manageable tasks which may themselves be decomposed.
  • Test and debug a program or algorithm to ensure it accomplishes the intended task.
  • Perform different roles when collaborating with peers during the design, implementation, and review stages of program development.

STANDARDS ALIGNMENT

CSTA's K-12 Standards 

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-DA-06: Organize and present collected data visually to highlight relationships and support a claim. Subconcept: Collection, Visualization & Transformation; Practice 7.1

1B-DA-07: Use data to highlight or propose cause-and-effect relationships, predict outcomes, or communicate an idea. Subconcept: Inference & Models; Practice 7.1

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

Next Generation Science Standards

5-ESS2-1. Develop a model using an example to describe ways the geosphere, biosphere, hydrosphere, and/or atmosphere interact.

CCSS ELA

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

World-Class Instructional Design and Assessment (WIDA) English Language Proficiency Standards

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

California's K-12 Computer Science Standards

3-5.CS.3: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.

3-5.DA.8: Organize and present collected data visually to highlight relationships and support a claim.

3-5.DA.9: Use data to highlight and/or propose relationships, predict outcomes, or communicate ideas.

3-5.AP.11: Create programs that use variables to store and modify data.

3-5.AP.12: Create programs that include events, loops, and conditionals.

3-5.AP.13: Decompose problems into smaller, manageable tasks which may themselves be decomposed.

3-5.AP.14: Create programs by incorporating smaller portions of existing programs, to develop something new or add more advanced features.

Science Content Standards

5-ESS2-1. Develop a model using an example to describe ways the geosphere, biosphere, hydrosphere, and/or atmosphere interact.

Common Core English Language Arts

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

California English Language Development Standards

CA ELD.3.C.11: Supporting own opinions and evaluating others’ opinions in speaking and writing

CA ELD.3.C.12: Selecting and applying varied and precise vocabulary and language structures to effectively convey ideas

Michigan Integrated Technology Competencies for Students (MITECS)

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-DA-06: Organize and present collected data visually to highlight relationships and support a claim. Subconcept: Collection, Visualization & Transformation; Practice 7.1

1B-DA-07: Use data to highlight or propose cause-and-effect relationships, predict outcomes, or communicate an idea. Subconcept: Inference & Models; Practice 7.1

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

Michigan Science Standards

5-ESS2-1: Develop a model using an example to describe ways the geosphere,
biosphere, hydrosphere, and/or atmosphere interact.

Michigan English Language Arts

Michigan ELA, Grade 3-8, Research, 8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

Michigan ELA, Grade 3-8, Range of Writing, 10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

WIDA English Language Development

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

Science Texas Essential Knowledge & Skills Grade 3

(b)(2) Scientific investigation and reasoning. The student uses scientific practices during laboratory and outdoor investigations. The student is expected to:
(A) plan and implement descriptive investigations, including asking and answering questions, making inferences, and selecting and using equipment or technology needed, to solve a specific problem in the natural world;

(b)(3) Scientific investigation and reasoning. The student knows that information, critical thinking, scientific problem solving, and the contributions of scientists are used in making decisions.

Science Texas Essential Knowledge & Skills Grade 4

(a)(1)(A) Within the physical environment, students know about the physical properties of matter including mass, volume, states of matter, temperature, magnetism, and the ability to sink or float. Students will differentiate among forms of energy including mechanical, light, sound, and thermal energy. Students will explore electrical circuits and design descriptive investigations to explore the effect of force on objects.

(b)(3) Scientific investigation and reasoning. The student uses critical thinking and scientific problem solving to make informed decisions. The student is expected to:

    (A) analyze, evaluate, and critique scientific explanations by using evidence, logical reasoning, and experimental and observational testing;

    (B) represent the natural world using models such as the water cycle and stream tables and identify their limitations, including accuracy and size; and

    (C) connect grade-level appropriate science concepts with the history of science, science careers, and contributions of scientists.

Science Texas Essential Knowledge & Skills Grade 5

(a)(1) In Grade 5, scientific investigations are used to learn about the natural world. Students should understand that certain types of questions can be answered by investigations and that methods, models, and conclusions built from these investigations change as new observations are made. Models of objects and events are tools for understanding the natural world and can show how systems work. They have limitations and based on new discoveries are constantly being modified to more closely reflect the natural world.

(a)(3) Recurring themes are pervasive in sciences, mathematics, and technology. These ideas transcend disciplinary boundaries and include patterns, cycles, systems, models, and change and constancy.

ELA Texas Essential Knowledge & Skills Grade 3

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) speak coherently about the topic under discussion, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively;

    (D) work collaboratively with others by following agreed-upon rules, norms, and protocols; and

    (E) develop social communication such as conversing politely in all situations.

ELA Texas Essential Knowledge & Skills Grades 4 & 5

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) express an opinion supported by accurate information, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively; and

    (D) work collaboratively with others to develop a plan of shared responsibilities.

(b)(13) Inquiry and research: listening, speaking, reading, writing, and thinking using multiple texts. The student engages in both short-term and sustained recursive inquiry processes for a variety of purposes. The student is expected to:

    (A) generate and clarify questions on a topic for formal and informal inquiry;

    (B) develop and follow a research plan with adult assistance;

    (C) identify and gather relevant information from a variety of sources;

    (D) understand credibility of primary and secondary sources;

    (E) demonstrate understanding of information gathered;

    (F) differentiate between paraphrasing and plagiarism when using source materials;

    (G) develop a bibliography; and

    (H) use an appropriate mode of delivery, whether written, oral, or multimodal, to present results.

§74.4. English Language Proficiency Standards

(c) Cross-curricular second language acquisition essential knowledge and skills.

(3) Cross-curricular second language acquisition/speaking.

(D) speak using grade-level content area vocabulary in context to internalize new English words and build academic language proficiency;

(E) share information in cooperative learning interactions;

(F) ask and give information ranging from using a very limited bank of high-frequency, high-need, concrete vocabulary, including key words and expressions needed for basic communication in academic and social contexts, to using abstract and content-based vocabulary during extended speaking assignments;

(G) express opinions, ideas, and feelings ranging from communicating single words and short phrases to participating in extended discussions on a variety of social and grade-appropriate academic topics;

(H) narrate, describe, and explain with increasing specificity and detail as more English is acquired;

CONCEPTS

Students will use loops, actions, and variables to collect and display data.

PARTS

  • Pico and Breadboard
  • (10) M2M Jumper Wires
  • (2) Alligator Clip Wires
  • (1) Bar Graph LED
  • (10) 330 Ohm Resistors
  • (1) 1 Mohm Resistors

GPIO SETUP

OVERVIEW OF STEPS

Step 1: 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.

Step 2: Grab Your Stuff

You will need:

  • Pico and Breadboard
  • (10) M2M Jumper Wires
  • (2) Alligator Clip Wires
  • (1) Bar Graph LED
  • (10) 330 Ohm Resistors
  • (1) 1 Mohm Resistors

You will also need:

  • Plastic Plant Stake
  • Vinyl Rainbow Sticker
  • (2) Copper Tape Strips
  • A small cup you can fill with water

Step 3: Prepare the Plant Stake

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.

Step 4: Make It Pretty

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.

Step 5: Build Your Circuit Board

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!

Step 6: Calibrate the sensor

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:

Step 7: Get the reading

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:

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.

Step 8: Get a "wet" reading

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:

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.

Step 9: How does the sensor work?

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.

Step 10: Light up some LEDs!

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:

Step 11: Mapping values

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:

Step 12: Try it out!

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:

Step 13: Make a sound

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.

Step 14: You Finished!

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