Lift-Off with CodeX - Mission 9: Automatic Garden!

Mission 9 Lesson Plan

Automatic Garden!

The crew cannot pack enough food for a stay on Mars, so they have to grow it. Students build a system that senses soil moisture and waters the garden on its own.

⏱ 45-60 min 🎯 Grades 4-12+ 💻 CodeSpace 📱 CodeX 🔌 Peripherals Kit 🐍 Python
View Lesson Outline
📋

Overview

A good garden needs watering. The crew will be unable to bring all the food necessary to survive on the surface of Mars, so they have to be able to grow their own once they get there, and they will want that process automated as much as possible. In this mission students construct a system that senses soil moisture levels and then automatically waters the garden.

Two new pieces of hardware show up here. The relay isolates the water pump's circuit from the CodeX, and the soil moisture sensor reads how much water is in the dirt by measuring conductivity. Students wire the pump through the relay's screw terminals, prime the pump with a CodeX button, then close the loop so the moisture reading decides when the pump runs.

🎯 Mission Goal: Students write code to simulate an automatic watering system.

🎯

Learning Targets

  • I can connect the relay to the CodeX.
  • I can connect the water pump to the relay and CodeX.
  • I can connect the soil moisture sensor to a divider and then the CodeX.
  • I can prime the water pump.
  • I can use the moisture sensor to trigger an event.
💡

Key Concepts

  • A relay is required to isolate circuits and use the water pump.
  • Like other analog sensors, the soil moisture sensor can be used to control a peripheral.
  • A button on the CodeX can be used to trigger an event, like priming the pump.

Assessment Opportunities

  • Check for Understanding in CodeSpace
  • Mission 9 Assignment
  • Draw a diagram of the relay and water pump setup
  • Exit ticket - explain the meaning of the values the soil moisture sensor returns
  • Submit and/or check the AutomaticGarden program
  • Journal entry on their learning experience
☑️

Success Criteria

  • Connect the water pump and turn it on and off.
  • Print the soil moisture reading to the REPL.
  • Use the soil moisture sensor to control the water pump.
  • Use a CodeX button to prime the pump.
🧰

Classroom Materials

  • Laptop/computer with the Chrome browser
  • CodeX and connecting cable
  • Small screwdriver
  • Two small containers or cups per CodeX
  • Water and soil for each system
  • Relay
  • Water pump
  • Soil moisture sensor and divider
Relay peripheral board for the CodeX with a blue three-terminal screw block labeled NC, common, and NO Small submersible water pump with red and black jumper wires and clear tubing Soil moisture sensor board for the CodeX with two gold prongs that push into soil Divider connector used to plug two peripherals into one CodeX port
🌍

Real-World Applications

🌱Farms and greenhouses use soil moisture sensors to decide when and how much to irrigate.
🏡Home gardeners use the same sensor in planters and lawn sprinkler controllers.
Relays show up all over the place, in thermostats, garage door openers, appliances, and car electronics.
💬Have students research where they can find relays in their everyday lives, then share what they found.
🚀

Extensions & Cross-Curricular

ChallengeAdd NeoPixels and LEDs to indicate the status of the soil moisture. Green could mean optimal moisture, yellow that watering is needed soon, and red that watering is needed now.
ChallengeShow the process of watering with a sequence of LED lights to simulate the water flow.
ChallengeUse the LCD screen to display real-time soil moisture levels.
ChallengeHave settings for different plants, and use a CodeX button to determine which settings to use.
Lang ArtsHave students write a lab report or technical paper about this mission.
MathExperiment with different times for the pump to turn on and measure the water output. Create a graph with the data. As an algebra extension, write the equation for the data.
ScienceTeach a lesson on conductivity. Use the soil moisture sensor in different substances.
BiologyTeach a lesson on plants and what they need to grow. How much sunlight? How much water? What are the alternatives?
🔤

Vocabulary

NC / NO - Terminals on the relay used for connecting peripherals. NO means normally open, and that is the terminal used most often.
Priming - The process of removing air from pump lines.
Conductivity - The ability of a material to conduct electricity. In this mission it is water. More water in the soil means more conductivity.
🐍

New Python Code

buttons.was_pressed(BTN_A)Returns True if the button was pressed since the last check, otherwise it returns False.
relay.valueThe property of the peripheral used to turn the relay on and off (True or False).
📐

Standards

CSTA Standards - Grades 6-8

2-CS-02 2-CS-03 2-DA-09 2-AP-10 2-AP-11 2-AP-13 2-AP-17 2-AP-19

CSTA Standards - Grades 9-10

3A-CS-03 3A-DA-11 3A-DA-12 3A-AP-13 3A-AP-16 3A-AP-17 3A-AP-18 3A-IC-26

CSTA Standards - Grades 11-12

3B-CS-02 3B-DA-05 3B-DA-06 3B-AP-10 3B-AP-14 3B-AP-15 3B-AP-17 3B-AP-21
📝
Preparing for the Lesson
  • Students need a computer or laptop with the Chrome web browser.
  • Make sure students can successfully log in to make.firialabs.com.
  • Each CodeX watering system needs two cups or containers. First the cups hold water and the pump moves it from one to the other. Then one cup gets soil in it.
  • This project can get a little messy. You might want to put down something to protect electronics, desktop surfaces, and the floor.
  • Gather enough small screwdrivers for students to share. They are needed to loosen and tighten the relay terminals.

🧑‍🏫
Teacher Notes
  • The screwdriver is used to loosen and tighten the relay terminals. Do not turn the screw too tightly, just enough to secure the wire.
  • Possible discussion or research questions: Where will the crew get the water and seeds? Will things grow on Mars like they do on Earth?
  • Extensions and cross-curricular projects are included to enhance the concepts in the mission. You can use the extensions to extend students' programming experience. A remix is not explicitly planned here, but you can add one as an option to give students additional learning. A remix is planned after Mission 9.
🗺️

Lesson Outline

🗣️Warm-up / Hook

Students access prior knowledge by answering the pre-mission questions in the assignment doc.

  • Ask: "The crew cannot pack enough food for the whole stay. What has to happen instead, and what does a garden need that Mars does not hand you?"
  • Ask: "How would a machine know that soil is dry? What could it measure?"
Teaching tip: Hold up a cup of dry soil and a cup of wet soil and ask the class how a computer could tell them apart. Conductivity usually comes out of the discussion on its own, which sets up the sensor before you name it.
📖Introduce the Mission

Front-load the two new peripherals and the wiring before students start typing.

  • Pass around the relay. Point out the NC, common, and NO screw terminals, and explain that the relay keeps the pump's circuit separate from the CodeX.
  • Demonstrate loosening and tightening a terminal with the screwdriver so students see how snug is snug enough.
  • Show the soil moisture sensor and the divider, and explain that it is an analog sensor like the ones from earlier missions.
  • Explain priming, and why air in the lines keeps a pump from moving water.
Teaching tip: Set the ground rules for water before any water comes out. Cups stay on the protected surface, and the pump gets tested over a container, never over a laptop.
💻Coding Time

Students work through the mission objectives in CodeSpace, taking notes and answering questions in their assignment doc as they go.

  1. Connect the relay to the CodeX, then wire the water pump into the relay's terminals.
  2. Turn the pump on and off in code with relay.value, pumping water from one cup to the other.
  3. Use buttons.was_pressed(BTN_A) to prime the pump.
  4. Connect the soil moisture sensor to the divider and the CodeX, then print its reading to the REPL.
  5. Build AutomaticGarden so the moisture reading decides when the pump runs.
  6. Complete the Check for Understanding in CodeSpace.
Teaching tip: Have students read the sensor in dry soil and again after watering, and write both numbers down. Those two readings are what they need to pick a threshold, and it saves a lot of guessing later.
🧑‍🤝‍🧑Class Debrief

Bring the class back together to lock in the relay, the sensor readings, and the feedback loop.

  • Ask: "Why does the pump need a relay instead of plugging straight into the CodeX?"
  • Ask: "What do the numbers from the moisture sensor actually mean, and how did you pick your threshold?"
  • Ask: "What would happen if the sensor came loose while the program was running?"
Teaching tip: Use the exit ticket here. Explaining what the sensor values mean shows quickly who understands conductivity and who just copied a number that worked.
✏️Wrap-up & Review

Students answer the reflection question in the assignment doc, add a journal entry about their learning experience, and submit.

Use the Mission 9 Review Questions or the Mission 9 Review Kahoot! through whichever method you prefer, class discussion, Kahoot!, or an LMS quiz.

Teaching tip: A remix comes after this mission. If students had extension ideas they did not have time for, note them now so they have somewhere to start.