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.
- 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)
-
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.
-
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)
-
-
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.
-
-
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.
The system works in two modes that run together:
-
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.
-
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.
- 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.
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.
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)
- 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.






