กลับไปหน้ารวมไฟล์
automated-irrigation-system-based-on-weather-forecast-09054e-en.md

Predictive Agriculture: IoT Irrigation

A standard moisture sensor just turns on the water when the dirt is dry. But what if a massive thunderstorm is arriving in 30 minutes? You just wasted gallons of water! The Smart Weather-Based Irrigation System uses internet predictions to act intelligently.

invisible_mess_glasses_relay_schema_1772681179521.png

The JSON API Request

The ESP8266 (NodeMCU) is the absolute requirement for this project.

  1. The ESP connects to your home Wi-Fi.
  2. It sends an HTTP GET request to OpenWeatherMap.org API for your specific zip code.
  3. The server replies with a dictionary string (JSON data).
  4. The ESP uses the ArduinoJson library to extract today's predicted rainfall percentage (e.g., "pop": 0.85, meaning 85% chance of rain).

The Decision Tree Logic

The code fuses physical sensor data with the virtual forecast data:

  1. It reads the local dirt via an Analog Soil Moisture Sensor. Result: DRY.
  2. It checks the API data: Chance of Rain: 85%.
  3. The Override: if (moisture < 300 && chanceOfRain < 50) -> Turn on the water. Because the chance of rain is 85%, the logic tree aborts the watering sequence! It knows nature will water the plants shortly.

Hardware Control Variables

  • ESP8266 NodeMCU or ESP32: The Wi-Fi API client.
  • Corrosion-Resistant Capacitive Soil Moisture Sensor v1.2 (Do NOT use the cheap exposed-metal resistive prongs, they will dissolve in the dirt).
  • 12V Water Solenoid Valve: Connected to a garden hose.
  • 5V Relay Module & 12V Power Adapter: To actuate the heavy valve based on the ESP's 3.3V signals.

ข้อมูล Frontmatter ดั้งเดิม

title: "Automated Irrigation System Based on Weather Forecast"
description: "Smart agriculture! Don't water plants in the rain! Build an ESP8266 system that checks the internet weather API before firing the water solenoids."
category: "Wireless & IoT"
difficulty: "Advanced"