Raspberry Pi Pico Auto Watering Device

by bentleyjamesroberts in Circuits > Raspberry Pi

47 Views, 1 Favorites, 0 Comments

Raspberry Pi Pico Auto Watering Device

71642f42-6aa8-4245-810a-3555dd415c73~1.jpg
1000013454.jpg

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

5525-02.jpg
download.jpeg
f6c4ab11-605f-48b2-941a-0750627a77e5~1.jpg
1000013462.jpg

. 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

1000013448.jpg
1000013454 (1).jpg

3d print the parts, you might have to play with the orientation

Wire the Components

1000013455.jpg

WIRING GUIDE

The following connections will link your Raspberry Pi Pico to the Servo Motor and the Soil Moisture Sensor.

SERVO MOTOR CONNECTIONS

  1. Servo Red Wire (VCC) to Pico Pin 40 (VBUS)
  2. Servo Black or Brown Wire (GND) to Pico Pin 38 (GND)
  3. Servo Yellow or White Wire (Signal) to Pico Pin 20 (GP15)

SOIL MOISTURE SENSOR CONNECTIONS

  1. Sensor VCC Pin to Pico Pin 36 (3V3 OUT)
  2. Sensor GND Pin to Pico Pin 33 (GND)
  3. Sensor Analog Out (AO) Pin to Pico Pin 31 (GP26)


Coding the Pico

Screen Shot 2026-03-16 at 10.40.38 PM.png

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

1000013451.jpg

place the sensor in the soil and hook up your tubing to a water source at low pressure and voila!