Skip to content

kalliangeli/iot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automatic Watering System with Arduino Mega


Overview

This project implements an automatic and remotely controllable watering system using an Arduino Mega 2560 and an Ethernet Shield W5100. The system monitors soil moisture, temperature, and humidity, while controlling a 12V pump (solenoid valve) and a 12V LED lamp through a 2-channel relay module.

Data is exchanged with the ThingSpeak IoT platform using two separate channels:

  • One for sensor data (temperature, humidity, soil moisture).
  • One for manual control commands (pump and lamp).

The system operates in two modes:

  • Automatic Mode – activates the pump when the soil becomes too dry.
  • Manual Mode – allows the user to control the pump and lamp remotely using the Virtuino mobile app.

Components

  • Arduino Mega 2560
  • Ethernet Shield W5100
  • Soil Moisture Sensor
  • DHT11 Temperature and Humidity Sensor
  • Solenoid Valve (12V Pump)
  • 12V LED Lamp
  • 12V 2-Channel Relay Module (High/Low Trigger)
  • 12V DC Power Adapter (for pump and lamp)
  • 5V Power Supply / USB Connection (for Arduino Mega)

Setup

  1. Arduino and Ethernet Shield Configuration

    • Stack the Ethernet Shield W5100 on the Arduino Mega.
    • Connect the shield to your local network via an Ethernet cable.
    • The Arduino will attempt to connect using DHCP and, if that fails, use the static IP 192.168.1.150.
  2. Sensor Calibration

    • Calibrate the soil moisture sensor by measuring values in dry and wet soil.

    • Example calibration values in this setup:

      • airValue_1 = 729 (dry)
      • waterValue_1 = 0 (wet)
  3. ThingSpeak Configuration

    • Create two channels on ThingSpeak:

      • Sensors Channel → stores temperature, humidity, and soil moisture data.
      • Commands Channel → receives ON/OFF commands for the pump and lamp.
    • Copy your Write API Keys from ThingSpeak and update them in the Arduino code.

  4. Virtuino Mobile App Setup

    • Download and install the Virtuino app.
    • Configure it to send commands to your ThingSpeak Commands Channel.
    • Use the same channel ID and API key defined in your code to control the pump and lamp.

Usage

The system works in two modes that run together:

1. Automatic Mode

  • The Arduino continuously reads:

    • Temperature and humidity from the DHT11 sensor.
    • Soil moisture percentage from the analog moisture sensor.
  • Every 20 seconds, it uploads the sensor data to the ThingSpeak Sensors Channel.

  • When soil moisture falls below 10%, the Arduino automatically:

    • Activates Relay 1 to turn ON the pump.
    • Keeps the pump ON until the soil becomes moist again.
  • The lamp is not automatically controlled in this version — it can be switched manually.

2. Manual Mode (Remote Control via Virtuino)

  • Every 15 seconds, the Arduino reads data from the ThingSpeak Commands Channel.

  • Commands sent from the Virtuino app can:

    • Turn the pump (Relay 1) ON or OFF manually.
    • Turn the lamp (Relay 2) ON or OFF manually.
  • This enables full remote control from your smartphone regardless of sensor readings.

3. Data Monitoring

  • All readings (temperature, humidity, soil moisture) are continuously sent to ThingSpeak.
  • You can view live charts and past trends directly on the ThingSpeak dashboard.
  • Both automatic and manual operations are reflected in the data.

Programming

The Arduino Mega 2560 is programmed to:

  • Initialize Ethernet communication and connect using DHCP or fallback static IP.
  • Read values from the DHT11 and soil moisture sensor.
  • Convert analog soil moisture readings into a percentage using calibration values.
  • Upload sensor readings to the ThingSpeak Sensors Channel every 20 seconds.
  • Read control commands from the ThingSpeak Commands Channel every 15 seconds.
  • Automatically start the pump when soil moisture drops below 10%.
  • Control the relays to switch the pump and lamp ON/OFF as needed.

System Diagram (Conceptual)

Arduino Mega 2560
│
├── Ethernet Shield W5100 → Internet (ThingSpeak)
│
├── DHT11 Sensor → Temperature & Humidity
├── Soil Moisture Sensor → Analog Input (A0)
│
└── Relay Module (2-Channel)
    ├── Relay 1 → 12V Pump (Automatic / Manual)
    └── Relay 2 → 12V Lamp (Manual via Virtuino)

Visuals

Ethernet Shield

img_6.png

Pump

img_5.png

Lamp

img_4.png

Relay Module

img_3.png

DHT11 Sensor

img.png

Final Setup

img_1.png img_2.png


Future Improvements

  • Make the lamp turn ON automatically whenever the pump is active.
  • Add timing control to limit watering duration.
  • Integrate data logging to an SD card for offline storage.
  • Implement notification alerts when soil moisture drops below a critical level.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages