Author: Crystal Mumtaz-Shah
Course: EECS 1021
Date: April 12, 2024
- Introduction
- Project Context
- Features
- Components
- Setup & Installation
- Implementation
- Testing
- Learning Outcomes
- Conclusion
This project is an automated plant watering system that monitors soil moisture levels via voltage readings from a sensor. It activates a water pump when the soil is dry (voltage > 3.4V) and stops when the soil is adequately moist (voltage β€ 2.8V). The system includes real-time data plotting and an OLED display for status updates.
Maintaining optimal soil moisture is critical for plant health. Manual monitoring is error-prone and time-consuming. This system automates the process by:
- Continuously measuring soil moisture.
- Watering plants when needed.
- Displaying real-time metrics (voltage, moisture level) on an OLED.
- Plotting data on a live graph.
- State Machine: Uses
if/else
statements to control the pump based on voltage thresholds. - Real-Time Data Plotting: Graphs moisture vs. time using Princeton's
StdDraw
library. - OLED Display: Shows moisture levels, voltage, and pump status.
- Emergency Stop: A button to manually turn off the pump.
ArrayList<Double> moistureList
: Tracks moisture values over time.HashMap<Integer, Double> voltageMap
: Maps timestamps to voltage readings.
- Arduino Communication: Uses
Firmata4J
to send/receive commands. - Components: Moisture sensor, MOSFET, 12V battery, water pump.
Component | Purpose |
---|---|
Arduino Grove Board | Controls all components. |
Moisture Sensor (A0) | Measures soil moisture. |
Water Pump (D2) | Delivers water to the plant. |
MOSFET | Regulates pump conductivity. |
12V Battery | Powers the pump. |
OLED Display | Shows real-time data. |
Laptop (IntelliJ) | Hosts the Java program. |
- Connect the moisture sensor to A0.
- Connect the MOSFET to D2.
- Power the pump with the 12V battery.
- Link the Arduino to the laptop via USB.
- Java (with
Firmata4J
library for Arduino communication). - Princeton Standard Library (
StdDraw
for graphing). - Arduino IDE (to upload Firmata firmware).
- Main Class: Manages the state machine, data collection, and Arduino communication.
- Graph Class: Handles real-time plotting using
StdDraw
. - Test Class: Validates sensor readings, pump control, and button functionality.
// State Machine Example
if (voltage > 3.4) {
pump.on();
oled.display("Watering...");
} else if (voltage <= 2.8) {
pump.off();
oled.display("Soil Moist");
}
// Data Collection
moistureList.add(moistureValue);
voltageMap.put(counter_Array, voltage);
A dedicated test class ensures:
- Board Connection: Confirms Arduino is detected.
- Sensor Accuracy: Validates moisture-to-voltage conversion.
- Pump Control: Tests activation/deactivation via voltage thresholds.
- Emergency Button: Verifies manual override functionality.
- CLO1: Built a test suite to validate hardware/software integration.
- CLO2: Integrated
StdDraw
for graphing andFirmata4J
for Arduino communication. - CLO3: Utilized
ArrayList
andHashMap
for efficient data tracking. - CLO4: Designed a state machine with
if/else
logic for pump control. - CLO5: Applied encapsulation (e.g., private variables) for modular code.
This project demonstrates the effective use of object-oriented programming and hardware integration to solve real-world problems. By combining Arduino, Java, and real-time data visualization, the system ensures optimal plant health with minimal manual intervention. Future enhancements could include IoT integration for remote monitoring!