User Tools

Site Tools


amc:ss2025:group-a:start

This is an old revision of the document!


Introduction

Efficient resource management in agriculture and landscaping has become critically important due to mounting environmental pressures. Two of the most pressing issues are the unnecessary overuse of water for irrigation—leading to water scarcity and waste—and the excessive application of fertilizers and chemicals, which infiltrate the soil and contaminate groundwater.

This project addresses these challenges by leveraging real-time, sensor-driven monitoring to optimize irrigation precisely when and where it’s needed. By integrating an ESP32 microcontroller with a VL53L8CX Time-of-Flight (ToF) sensor, the system can detect the presence and position of plants or objects in a monitored area. Coupled with instant wireless data transmission and automated control of watering systems, the setup enables the following environmental benefits:

  • Water Conservation: Irrigation is triggered only when the sensor detects plant presence and proximity, reducing unnecessary watering and helping to preserve scarce water resources.
  • Targeted Fertilizer Application: By knowing exactly where and when plants are present, the system can help guide precise application of fertilizers and reduce runoff—limiting the amount of chemicals infiltrating natural soil and groundwater.
  • Reduced Environmental Footprint: Intelligent control systems such as this not only save resources but also help reduce the carbon footprint and ecological impacts associated with traditional, less-efficient agricultural practices.

This project demonstrates how low-cost, network-connected sensors and automation hardware can contribute to sustainable practices in agriculture, urban gardening, or landscape management. The following report details both the hardware and software necessary to build the system, so others can replicate and further adapt it to address environmental needs in their own communities.

Materials and Methods

Materials

  • ESP32 Development Board: Primary controller running FreeRTOS.
  • VL53L8CX ToF Sensor Module: Delivers 8×8 grid distance measurements for object/plant detection.
  • Push-Button Switch: User input, event annotation.
  • LED, relay, or actuator (connected to GPIO7): Controls irrigation.
  • Wiring/Breadboard or PCB: For sensor, switch, and actuator connections.
  • Client computer/device: Receives sensor data via TCP.
  • Power Supply: For ESP32 and peripherals.
  • Wi-Fi Network: For ESP32 to connect and transmit data.

Pin Assignments

Function ESP32 GPIO Notes
I2C SCL 9 ToF sensor
I2C SDA 8 ToF sensor
ToF sensor reset 5 XSHUT line
Output (Actuator) 7 Controls valve/LED/relay
Input (positioning marks reader) 4 With internal pull-up enabled

Methods

System Design

The system combines real-time sensing, network connectivity, and actuator control:

  • Wi-Fi Setup: ESP32 connects as a station to a Wi-Fi network.
  • TCP Server: Listens for clients on port 5055, streams data on connection.
  • Sensor Initialization: VL53L8CX set to 8×8 mode, 10Hz data rate, using I2C.
  • Distance Measurement: ESP32 polls the sensor, collects a 64-value frame representing distances in mm.

Object/Plant Detection:

  • Calculates background distance (median).
  • Compares each pixel to background; detects objects (plant presence) using a threshold.
  • Calculates weighted centroid of detected zone.

Actuator Control:

  • If detected object (plant) is close to the center, triggers GPIO7 (e.g., opens/closes irrigation valve).
  • Otherwise, actuator remains off, preventing unnecessary watering.

Button Interrupts: Debounced, stamp events for annotation (e.g., manual override/mark).

Data Streaming: Sensor data frames, timestamps, and event marks are sent to network clients for monitoring or logging.

Software Flow

Written in C using ESP-IDF framework.

  • Uses FreeRTOS for multitasking: independent tasks for TCP communication, sensor polling, and button handling.
  • Hardware timer (GPTimer) ensures accurate event timestamps and debouncing.
  • All configuration parameters (SSID, pins, thresholds) are user-adjustable.

Assembly

  • Wire the ESP32 to the VL53L8CX using I2C (SCL: 9, SDA: 8) and sensor XSHUT to GPIO5.
  • Connect button to GPIO4 (with internal or external pull-up to 3.3V).
  • Connect actuator (e.g., relay valve) control input to GPIO7.
  • Flash the ESP32 with the provided code, making any adjustments for your setup.
  • Start ESP32; ensure it connects to Wi-Fi.
  • Connect a client to ESP32's IP on TCP port 5055 to view or log streaming data.

Results

Functional Testing

When the ESP32 is powered and connected to Wi-Fi:

  • The VL53L8CX sensor continuously scans its field, providing an 8×8 distance map.
  • The ESP32 detects objects (e.g., plant) based on pixels closer than the background by a given threshold.
  • When an object is close to the central region of the sensor frame (representing a plant directly under the sensor), GPIO7 is activated—demonstrating selective and efficient irrigation.
  • Actuator remains off when no plant is detected or it is not near the center, preventing watering of bare soil and reducing excessive chemical/fertilizer application.
  • All sensor frames and button events are timestamped and streamed live to TCP clients for monitoring or data analysis.

Environmental Impact

  • Water Use Reduction: System only waters when plant presence is confirmed and in the precise location, minimizing waste.
  • Reduced Chemical Runoff: As irrigation is limited to when and where needed, less fertilizer is washed into groundwater.
  • Data Gathering: Collected distance/time data supports further optimization, trend analysis, and integration with weather/fertilization schedules.

Reliability

  • Button interrupts reliably send annotated “mark” frames for event logging or manual input.
  • The system is resilient to network disconnects, with reconnection and data buffering as programmed.

Discussion

  • This system showcases the potential of integrating low-cost sensor networks and automation for sustainable environmental stewardship:
  • Precision Irrigation: Only waters when plant is actually present, avoiding traditional timer-based schemes that can waste water and leach chemicals.
  • Scalability: Multiple ESP32/sensor nodes can be deployed across large fields or greenhouses, each acting independently but monitored from a central server.
  • Customization: Sensor thresholds, actuator logic, and even fertilization scheduling can be tailored using the streamed data, allowing fine-grained environmental control.

Limitations & Improvements:

  • Current system is distance-based; integrating soil moisture or plant health sensors could further refine watering decisions.
  • Wireless reliability is dependent on network strength; alternative protocols (e.g., LoRa) could be used in rural deployments.
  • Data encryption/authentication could be added for more secure remote management.

In summary, this project presents a practical, adaptable example of how sensor-driven automation can help address water and chemical conservation challenges in environmental and agricultural settings. The design and methods are fully replicable, providing a baseline for further innovation and environmental impact.

amc/ss2025/group-a/start.1753773735.txt.gz · Last modified: 2025/07/29 09:22 by 35120_students.hsrw