Raspberry Pi Pico Auto Watering Device
by bentleyjamesroberts in Circuits > Raspberry Pi
47 Views, 1 Favorites, 0 Comments
Raspberry Pi Pico Auto Watering Device
this is a rpi pico automatic watering device that takes the moisture from the soil and when it drops too low it will open a valve to allow water to flow from a source to the soil
Supplies
. a microcontroller i used an rpi pico which is an inexpensive board-$4
. lm393 moisture sensor-$1.50
.sg90 servo-$2.50
.a few wires
.3d printer and filament i recommend petg
.some garden tubing i used 1/4 tubing meant for building drip lines
3d Print the Parts
3d print the parts, you might have to play with the orientation
Wire the Components
WIRING GUIDE
The following connections will link your Raspberry Pi Pico to the Servo Motor and the Soil Moisture Sensor.
SERVO MOTOR CONNECTIONS
- Servo Red Wire (VCC) to Pico Pin 40 (VBUS)
- Servo Black or Brown Wire (GND) to Pico Pin 38 (GND)
- Servo Yellow or White Wire (Signal) to Pico Pin 20 (GP15)
SOIL MOISTURE SENSOR CONNECTIONS
- Sensor VCC Pin to Pico Pin 36 (3V3 OUT)
- Sensor GND Pin to Pico Pin 33 (GND)
- Sensor Analog Out (AO) Pin to Pico Pin 31 (GP26)
Coding the Pico
i recommend using arduino ide but to do so will require adding support for the board, so first go to preferences then go down to add board url and paste this https://github.com. once thats done you can add this code {#include <Servo.h>
// PIN DEFINITIONS
const int SOIL_PIN = 26; // Soil Sensor Analog Pin
const int SERVO_PIN = 15; // Servo Data Pin
// CUSTOMIZABLE SETTINGS
const int DRY_THRESHOLD = 750; // Higher = Drier (Range 0-1023)
const int WATER_ANGLE = 0; // Angle to open the valve/pour
const int CLOSED_ANGLE = 90; // Angle to stop watering
const int WATERING_TIME = 3000; // How long to pour (ms)
Servo waterServo;
void setup() {
Serial.begin(115200);
// Initialize Servo
waterServo.attach(SERVO_PIN);
waterServo.write(CLOSED_ANGLE); // Start in the closed position
// Set ADC Resolution for Pico
analogReadResolution(10);
Serial.println("--- System Online: Monitoring Soil Moisture ---");
}
void loop() {
int moistureLevel = analogRead(SOIL_PIN);
Serial.print("Current Soil Reading: ");
Serial.println(moistureLevel);
// Logic: If soil is drier than our threshold...
if (moistureLevel > DRY_THRESHOLD) {
Serial.println("STATUS: Dry! Commencing Watering...");
waterServo.write(WATER_ANGLE); // Move to pour
delay(WATERING_TIME); // Wait for water to flow
waterServo.write(CLOSED_ANGLE); // Return to closed
Serial.println("STATUS: Watering Complete. Waiting for absorption...");
delay(10000); // Wait 10 seconds to prevent over-watering
} else {
Serial.println("STATUS: Soil is healthy.");
}
delay(5000); // Check every 5 seconds
}
Setup With Plant
place the sensor in the soil and hook up your tubing to a water source at low pressure and voila!