Inspiration

Living in the Bay Area, we all know how real droughts are and how crucial water conservation becomes. Seeing those water restriction signs go up while timer-based sprinklers are still watering lawns, sometimes even in the rain, always felt incredibly frustrating. We're asked to save every drop, yet so much seems wasted by inefficiency! On a smaller scale, trying to keep my own indoor plants alive often felt like a guessing game. Was I giving them too much water, or too little? It's easy to get wrong, and both waste water and hurt the plant. I figured many people probably feel that same frustration.

I wondered, could learn some Python skills into making something I'm really passionate about, to build a better way? Could technology help us be smart and conserve our resources and better plant caretakers, especially when water is so precious? That challenge excited me. This simulation is my answer. An attempt to model an intelligent system that waters plants based on actual need, not just the clock, aiming for both conservation and healthier, happier plants.

What it does

This project simulates an indoor plant watering system. It uses a virtual moisture sensor to check the soil's condition. Based on the moisture level, it decides whether to water the plant or wait. The simulation aims to keep the plant within its ideal moisture range (not too wet, not too dry) to optimize its health. It uses Pygame to visually show the plant's health, the soil moisture level, and when watering occurs, providing real-time feedback on the system's decisions.

How I built it

The Logic (plant_logic.py): I started with the basic rules: How does the soil moisture change? How does plant health work? What does the sensor do? I made Python classes for these parts using Object-Oriented Programming.

The Visuals (pygame_interface.py): Next, I used the Pygame library to draw everything: the pot, the plant (changing its color based on health), and the text showing moisture and health levels.

Putting it Together (main.py): This script runs the show. It creates the Soil, Plant, and Sensor objects, runs the simulation day by day, decides when to water based on the sensor reading, and tells Pygame what to draw on the screen.

Testing: I kept running the code, watching the simulation, and tweaking parameters like drying speed and health changes until the simulation behaved reasonably well.

Challenges I ran into

Pygame Details: Getting drawings to look right and appear in the correct spot took some time and debugging.

Getting the Numbers Right: Figuring out realistic values for how fast the soil should dry or how much the health should change took some guessing and testing.

Time Limit: Learning and finishing the code and the presentation was a rush.

Accomplishments that I'm proud of

Successfully creating a working simulation that demonstrates the core "measure-first" watering logic.

Integrating the backend simulation logic (Python classes) with a visual frontend (Pygame).

Learning and implementing Pygame for the first time to create an interactive display.

Applying Object-Oriented Programming concepts to structure the code cleanly.

Building a project that addresses a real-world problem like water conservation.

What I learned

Better Python: I got more practice with Object-Oriented Programming (OOP) by making separate classes for Soil, Plant, and Sensor. It helped organize the code, kind of like building with digital blocks.

Using Pygame: I'd never used Pygame before. It was fun (and a bit challenging!) to figure out how to draw the plant, show the text, and make things change on the screen based on the code. Seeing my code create visuals was really cool.

Simulating Reality: I learned how to translate real-world ideas (like soil drying out) into simple code rules.

Finding Bugs: I got better at figuring out why things weren't working by using print statements to track what was happening.

What's next for Indoor Plant Sprinkler Sim

Enhance the simulation with different plant profiles requiring unique moisture levels.

Improve the visual details or add simple animations in Pygame.

Take the leap and build a physical prototype using actual hardware soil sensors, a microcontroller (like Raspberry Pi or Arduino), and a small water pump.

Built With

Share this project:

Updates