Lift-Off with CodeX - Mission 9: Automatic Garden!
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.
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.
Digital Resources
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
Real-World Applications
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
📐
Standards
▾
CSTA Standards - Grades 6-8
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
- 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.
- 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
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?"
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.
Students work through the mission objectives in CodeSpace, taking notes and answering questions in their assignment doc as they go.
- Connect the relay to the CodeX, then wire the water pump into the relay's terminals.
-
Turn the pump on and off in code with
relay.value, pumping water from one cup to the other. -
Use
buttons.was_pressed(BTN_A)to prime the pump. - Connect the soil moisture sensor to the divider and the CodeX, then print its reading to the REPL.
- Build AutomaticGarden so the moisture reading decides when the pump runs.
- Complete the Check for Understanding in CodeSpace.
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?"
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.