Introduction: Auto Plant Watering System
I had this idea and I realised after that other people had too but thought I'd knock something up from parts I had. I was initially planning this as a how to build it for £5 but in all reality i think this probably comes under that quite easily without any major concessions. I took a photo of the parts I was planning to use but then I decided I would go the prototype route with no soldering so used a breadboard and the appropriate connectors. I don't do this enough really and it saves faf later on by not having to resolder things. I got this up and running really quickly which i was happy with.
I've put a small video showing the design in a little more detail which is included.
Oh and you shall notice I'm actually missing some tubing as I've not had a chance to purchase a tube to run from the water reservoir to the plant pot yet, going to get it this week.
Step 1: Wiring It All Up
I used the following components
- Arduino Uno (clone)
- 2 x 220 resistor
- Red LED
- Green LED
- Relay module (link)
- Soil Moisture sensor (link)
- 5-6v pump (link)
- Breadboard
- Powerbank
The soil moisture sensor was connected to pin 2
The relay module was connected to pin 3
The LED's were connected to pin's 4 and 5
Attachments
Step 2: Code
The code is quite basic but I've put it on github as i plan to work on this so it's nice to have a common place to hold the code.
https://github.com/chickey/autowater
/*
Flower Soil Mosture Sensor
D2 - Soil Mosture Sensor
D3 - Relay module
D4:D5 - LEDS 1,2
LED1 - Green
LED2 - Red
Connect the Soil Moisture Sensor to Digital input pin 2 and your 2 led's to digital out 4-5
*/
int moistureSensor = 2;
int relay = 3;
int led1 = 4;
int led2 = 5;
void setup()
{
// setting the led pins to outputs
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
// setting the Relay pin to output
pinMode(relay, OUTPUT);
// Serial Begin so we can see the data from the moisture sensor in our serial input window.
Serial.begin(9600); }
// the loop routine runs over and over again forever:
void loop()
{
// read the input on digital pin 2:
int sensorValue = digitalRead(moistureSensor);
// print out the value you read:
Serial.println(sensorValue);
digitalWrite(relay, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
if (sensorValue == 1) {
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(relay, LOW);
Serial.println("Watering");
delay(10000);
// run pump for 10 seconds
Serial.println("Finished watering"); }
delay(1000);
// delay 1 second between reads
}
Step 3: Conclusion
This is an extremely simple design and I plan to expand on it more, possibly looking into using either WiFi via ESP8266 or via radio with a NRF24L01+. The WiFi option has the advantage that I may be able to do away with the arduino then, just need to learn a bit of lua.
I should add my plants don't normally look like that lol, I grabbed a nearly dead plant from outside just to test the sensor with.