Skip to content
Forward Education logoForward Education logo
Middle School Smart Farming: How One Classroom Used Coding and Data to Grow Plants

Middle School Smart Farming: How One Classroom Used Coding and Data to Grow Plants

What happens when you combine sensors, sustainability, and a group of curious students? In one middle school classroom, it sparked a hands-on learning experience that turned coding and data into real plant growth. Using the Data-Driven Smart Farming lesson, students built and programmed automated watering systems to support seed germination and plant growth—all while learning how technology can make agriculture more efficient and sustainable. This project also ties into the United Nations Sustainable Development Goals (SDGs), helping students see how their classroom learning connects to global challenges like food security, clean water, and responsible consumption.

This project brought science, coding, and environmental awareness to life. It wasn't just about growing plants; it was about growing problem-solvers.

Special thanks to Peter Anello and students at Nipissing-Parry Sound CDSB and Mother St. Bride Catholic Elementary School for sharing photos of their PD Day Workshop with the Climate Action Kit.

Hands-On STEM: Smart Farming with Sensors and Code

With excitement (and a few paper towels) in hand, students began by exploring how moisture sensors work. Testing the sensor outside of the soil gave them a clear understanding of how the data would change based on water levels. Once comfortable, they connected their microcontroller to a small pump, coded a system to respond to moisture readings, and got their seeds started.

As the plants grew, students took ownership over their systems. They added labels to track the type of seed and the start date. Some even customized their code to deliver different amounts of water depending on the plant type—a thoughtful step rooted in real-world agricultural challenges.

Exploring Loops and Logic: How Students Coded Their Watering System

This project also provided a meaningful opportunity to dig into programming concepts. Here’s a quick breakdown of how the code works:

  • Pressing Button A starts the sequence. Each time it's pressed, the system checks the current moisture level of the soil.

  • A "while" loop is used to monitor the sensor continuously. As long as the moisture level is below 20%, the pump stays on.

  • Inside the loop, the pump turns on for 500 milliseconds, then the system pauses for 1000 milliseconds before checking the moisture level again.

  • Once the moisture reading hits 20% or more, the condition is no longer true, the loop ends, and the pump turns off automatically.

This simple logic reinforces key computer science concepts like event handling, conditional logic, and looping in a tangible, hands-on way.

Classroom Tips for Coding and Smart Agriculture Projects

Here are a few classroom-tested tips to make your smart farming project run smoothly:

  • Get hands-on with the sensor first: Let students test the moisture sensor before adding water to understand how the readings change.

  • Don’t leave the pump in water too long: It's built for quick action, not long-term soaking.

  • Keep paper towels nearby: A little spill is part of the process!

  • Use labels: Note the student name, type of seed, and start date for easy tracking.

  • Different seeds, different needs: Encourage students to tweak their code to match each plant's water requirements.

Standards Alignment: NGSS, CSTA, CTE Connections, and Ontario Science and Math

This lesson is deeply aligned with multiple curriculum areas, including:

View the full list of curriculum connections here

Explore the Smart Farming Lesson for Grades 6–8

You can bring this same lesson to your students. The Data-Driven Smart Farming activity blends real-world technology with purpose-driven learning—and it starts with a single seed.

Data-driven Smart Farming | Forward Education

Got photos from your classroom? We'd love to see how your students take on smart farming. Tag us on social or send us a note!

Cart 0

Your cart is currently empty.

Start Shopping
close
close
close
I have a question
sparkles
close
product
Hello! I am very interested in this product.
gift
Special Deal!
sparkles