Easiest Arduino Smart Plant Watering

16,957

94

55

About: Elecrow is an open hardware facilitation company based in Shenzhen. We integrate resources to serve new era of innovation. To make your making and innovation easier, we offer various development platform, mo...

Last time we wrote intructable on how to make an automatic plant watering system with arduino and sensors, our article gained a lot of attention and great feedback.

Afterwards, we’ve been thinking how could we make it better. It seems as our office grown also the number of flower pots in the office grown as well, and we needed a better more friendly watering solution. We came up with easy-to-make solution that will let us water up to 4 plants with one node! That’s incredible. With the previous solution we could only water 3 and also we needed them to be located one next to the other, which made it less convenient.

Our Solution: Smart Pump Shield

We got frustrated with all the jumpers and prototype boards so we came up with idea to develop our own shield. The shield contains 5 relays – 4 for the water switching mechanism and another one for the water pump, it has dedicated Crowtail interfaces for our sensors which eliminate the need for jumpers and breadboards and make the kit easy and fun to use! You can also use it as normal without Crowtail connectors for other projects you might come with!

Step 1: Gathering the Parts

To Process this instructables we'll need to use “Crowtail smart pump kit” which the link to it can be found right

The Kit will include:

- x4 Crowtail soil moisture sensors

- x1 Crowtail Smart Pump Shield

- x1 Crowtail Water Pump

- x1 12V Adapter

- x1 Four channels water valve

- x1 one long water pipe (later we'll cut it to 6 pieces for our project)

You will also Need Crowduino Uno / Arduino Uno for the project

Why This Kit?

- Eliminate the need of breadboard and jumpers

- Less mess more productivity!

- Easy to use, just plug and play, anyone can do it!

- 12v connector for the pump and split into 5v for the arduino as well!

- Control up to 4 flowers at once with one shield!

Step 2: Uploading the Code to the Arduino Board

The next step will be uploading our code to the Arduino board,

we do it first because after connecting all the sensors and pumps it might get a little bit messy and difficult to connect, better do it now when you only have the board in your hand!

the code can be found at the bottom of this instructable, make sure that you choose Arduino Uno regarding the device you use (Arduino Or Crowduino Uno) in the ArduinoIDE.

If you are not familiar with Arduino, follow the following steps:

1. connect your Arduino board by USB to your computer

2. open Arduino IDE (if you don't have it, make sure to download it from their official website)

3. Open the project we gave at the bottom of the Instructable page

4. On top of the Arduino IDE choose "Tools > Board > Arduino ATmega328"

5. Click the V sign to verify the code and then right next to it the arrow-right button to push the code!

Step 3: Connecting the Shield to the Arduino Board

Easy as it sounds - the next step will be connecting our smart pump shield to the arduino board.

NOTE: When you putting them one on top the other and connecting them together, make sure to do it slowly and easily as the Smart pump shield pins might be a bit sensitive.

After putting them together - it should look exactly as the picture below

Step 4: Connecting the Pump and the Switch

The Next step will be connecting our 4 channels switch that will control the water direction and the pump,

Moving to the switch:
It's difficult to miss - the switch is the biggest interface on the shield. make sure you place it at the right direction and it should *click* Now we got both pump and the switch connected to the board successfully

We'll start from the water pump:

if you look closely at your board, there are 6 crowtail interfaces aligned one with each other, this is the sensors interfaces. next to that there is one small lonely interface, smaller than the other one's - that's the pump interface.

you'll know it's the right interface when it will fit - the pump is the smallest interface between them all.

Step 5: Connecting the Soil Moisture Sensors

The next step will be connecting the soil moisture sensors, we'll use this sensors to detect the soil level inside the plants and determine if they need water or not.

We'll connect it by using the 4 out of 6 Crowtail sensors interfaces, because we use 4/6 we can use the other two to give more advanced features to our project, few examples can be:

- adding light sensors to know if the plants get enough lights

- adding humidity sensor to detect if the humidity is alright

- temperature sensor to make sure it's not too hot or too cold

- rain sensor to detect if it's raining now and no need to water them and more ...

The order of the sensors is as following

- A0 - Flower number 1, in the switch it's the first one close to the water source interface

- A1 - Flower Number 2, in the switch it's the second one from the direction of the water source interface.

- A2 - Flower Number 3, in the switch it's the third one from the direction of the water source interface.

- A3 - Flower Number 4, in the switch it's the fourth one from the direction of the water source interface.

NOTE: Make sure it's correct else the pump will give water to the wrong flower!

Step 6: Connecting the Water Pipes

This step require to gather some scissors or knife.

we'll need to take the water pipe from the kit and cut it to 6 parts.

make sure the length is identical and better if the pipe that goes inside the water source (in our case it's a bottle of water) will be long enough to reach the water.

after we finish cutting it - it's time to connect them!

we'll connect 2 of them into our pump, one of the pump sides sucking the water while the other one pushing the water out. it might be confusing at first which one is which but if you look very very carefully on the pump it says "IN" and "OUT" the one that is "IN" should go to the water source while the one that is "OUT" should go to the switch.

After connecting the pump we'll need to wire it to our switch. the switch have 5 inputs. 4 of them are lined up, those are going directly to the flowers, the one that is on the left side, goes to the pump OUTPUT.

The switch works by closing a circuit at specific channel - it will let the water flow, if no circuit been closed, the water could not flow. we'll be opening the channels by the demand of the flowers to get water, that way - only the flowers that need in water, will get it.

Step 7: Powering It Up!

The Last step will be - Powering it up!

Now, this is one of the best features in our board. both the pump and the switch requires 12v input while the arduino can only stand 5v, so instead of supplying different power supplies to the arduino, the pump and the switch we made our shield to split the power between the arduino and the other devices. that way - the arduino will get 5v while the pump and the switch will get 12v.

NOTE: When connecting the power supply, make sure to connect it into the shield board and NOT the arduino. there is NO need in two power supplies as the shield will give power to the arduino as well.

We hope you find this instructable useful, easy and fun! we worked hard to make the most simple yet powerful kit, you can use the smart shield not only for this projects but for others too! let us know what will you make and the way you use our kit.

2 People Made This Project!

Recommendations

  • Toys Contest

    Toys Contest
  • First Time Author

    First Time Author
  • PCB Contest

    PCB Contest

55 Discussions

0
None
Ale_hub

Question 5 weeks ago

I have a smart pump board v2.0! how does it work? what's the code?

A330FC4C-C130-431D-935F-0424354C71BC.png
0
None
tuner2

Question 8 weeks ago on Introduction

I have the elecrow plant watering kit, how do I set the code so it only waters 2 plants instead of 4. Thanks

0
None
LuciaB17

Question 2 months ago on Step 6

How do you control water level for the water pump?? I want to recover water excess from my pot garden and I want when the water level is down in the tank pump, to get fresh water from the tap. But anyone notices how to avoid pump to work on dry. Like that I can get a completely closed system.

0
None
russm3086

Question 3 months ago

Where can I get longer cables for the moisture sensors? I am looking for something around 5 meters. Also I need to get an extension for the 4 way valve. Thanks

0
None
IljaS6

3 months ago

Thank you for the amazing code where all plants are checked and watered individually, just as a thought, I am trying now to change pump running time by using millis(), and get rid of most of the delays() to make code more flexible, and this doesn't seem to be a very easy task because delays are positioned outside the main loop. May be someone has also tried to do that and can share his findings?

1
None
kingofwoods

7 months ago

Anyone interested in better code? I adjusted the code so your pump doesn't pump when it's not safe (closed valves, too early starting). You get feedback on the serial monitor screen now also. My script waters plants, check a few minutes after water is settled and if everything s ok then it doesn't check again for the next 8 hours.

Also, the code that was given here didn't work propperly for me. Pump and valves sometimes just kept pumping and acting strange.

EDIT: NEW CODE WITHOUT ERRORS. Sorry old code was wrong old piece of copy pasta code. This new piece should work.

// set all moisture sensors PIN ID

int moisture1 = A0;

int moisture2 = A1;

int moisture3 = A2;

int moisture4 = A3;

// set water relays

int relay1 = 3;

int relay2 = 4;

int relay3 = 5;

int relay4 = 6;

//init valve nr

int x = 0;

// set water pump

int pump = 2;

//Water correct plant function

void waterPlant(int x) {

Serial.print("Opening: ");

Serial.print(x);

//Open valve x ==> x will contain value of correct relay[1-4]

digitalWrite(x, HIGH);

//We wait 0.5 seconds before opening pump so we are sure valve is open. This will prevent the pump from pushing water to a closed valve and risking the tubes to leak or wose, break loose.

delay(500);

//Open pump for 3 seconds

digitalWrite(pump, HIGH);

delay(10000);

//close pump

digitalWrite(pump, LOW);

delay(500);

digitalWrite(x, LOW);

//Make sure all valves are closed again.

closeAll();

}

void setup() {

// declare relay as output

pinMode(relay1, OUTPUT);

pinMode(relay2, OUTPUT);

pinMode(relay3, OUTPUT);

pinMode(relay4, OUTPUT);

// declare pump as output

pinMode(pump, OUTPUT);

// declare the ledPin as an OUTPUT:

Serial.begin(9600);

}

void loop() {

//print sensor values.

Serial.print(F("Sensor 1: "));

Serial.println(analogRead(moisture1));

Serial.print(F("Sensor 2: "));

Serial.println(analogRead(moisture2));

Serial.print(F("Sensor 3: "));

Serial.println(analogRead(moisture3));

Serial.print(F("Sensor 4: "));

Serial.println(analogRead(moisture4));

Serial.println("Check moisture");

//Go to moisture checkup function to se if plants need watering

checkMoisture();

// wait 8 hours and repeat the process

Serial.print("wait 2 hours \n ++++++++++++++ END +++++++++++++ \n");

delay(7200000);

}

// check which plant need water

// and open the switch for that specific plant

void checkMoisture() {

if (analogRead(moisture1) <= 550) {

waterPlant(relay1);

}

if (analogRead(moisture2) <= 550) {

waterPlant(relay2);

}

if (analogRead(moisture3) <= 550) {

waterPlant(relay3);

}

if (analogRead(moisture4) <= 550) {

waterPlant(relay4);

}

delay(120000);

if (analogRead(moisture1) <= 450 || analogRead(moisture2) <= 450 || analogRead(moisture3) <= 450 || analogRead(moisture4) <= 450) {

checkMoisture();

}

else {

closeAll();

}

}

// turn pump & valves off just to be sure.

void closeAll() {

Serial.println("closing pump + valves!");

digitalWrite(pump, LOW);

digitalWrite(relay1, LOW);

digitalWrite(relay2, LOW);

digitalWrite(relay3, LOW);

digitalWrite(relay4, LOW);

}

14 replies
0
None
MaximS23kingofwoods

Reply 3 months ago

Hi,

Good job! Thanks for refactoring that code. One question: which exactly board do you personally use? I cannot prove it, but I guess there are some problems with standard Arduino Uno... I switched to Maker Uno board - works perfectly.

0
None
JefB7kingofwoods

Reply 5 months ago

Hey, I used your code with minor adaptations to also use a water level sensor and light sensitive resistor to only operate when there is sufficient water and during daytime.

Another option I am trying to add is sleep mode to lower power consumption and maybe run it on a battery because my plants are outside and I want it to work remotely.

Thanks a lot for the code, helped me a lot!

0
None
kingofwoodsJefB7

Reply 5 months ago

I'm interested myself in the sleep-mode. IF you found a good way to do that plz can u share your knowledge with us :)

0
None
Paxx_277kingofwoods

Reply 6 months ago

Thanks for the code. I tried to upload it but i get the following error message: smart_pump_smarter.ino:67: error: 'x' was not declared in this scope

How can I define x? I can't figure it out.. Thanks!

0
None
Paxx_277Paxx_277

Reply 6 months ago

Ok got it. The definition of x was missing. Now it works!

//Water correct plant function

void waterPlant(int x) {

0
None
MortenB13Paxx_277

Reply 5 months ago

got around to testing the code now and it did absolutly nothing, did I missunderstand something ? uploaded the code and plugget it in and nothing.

edit: now found out it only work while connected to the laptop with the usb cable, any ideas ?

0
None
Paxx_277MortenB13

Reply 5 months ago

Do you have plugged in the power cable directly to the Pump Shield and made sure, that the 12V power button on top of the sield is on? If you just can hear clicking noise prom the relays but no pump noise, the shield is working but there is no 12V-power to the pump an valve.

0
None
MortenB13Paxx_277

Reply 5 months ago

yeah, the cable is connected to the pump shield (orignially I connected it wrong a month back, hope it didnt fry it) , and as long as the arduino is connected to the computer with USB it pumps and runs fine. The second I unplug the USB it stops working. THe power button on top of the shield is depressed and should be okay.

0
None
kingofwoodsMortenB13

Reply 5 months ago

If you unplug the usb, does your arduino still light up or is it powered down?

0
None
MortenB13kingofwoods

Reply 5 months ago

I am not really sure if its powered down or not.

when its only plugged into the USB it blinks and clicks on a regular interval.

when plugged into the power plug only nothing happens, no lights, sound or anything.

when plugged into both USB and power it runs the script as expected. the pump runs and the valves open and close.

0
None
JefB7MortenB13

Reply 5 months ago

Hi Morten,

There is a push switch next to the power supply on the interface board. You might want to check if it is on? It should be down to be on.

Also you need the power because over usb I don't think you can draw sufficient current to run the pump and power the valves. Not sure though.

0
None
kingofwoodsMortenB13

Reply 5 months ago

Sorry but I have no clue. i'm fairly new to the all Arduino stuff myself. All I can say this code works for me. It has been working for over a month almost now without me having to interveen whatsoever. The only thing I do is fill my water reservoir. I'll check and run the code again tonight when I get home.

You can always try to adjust the delay() times to a much shorter periode to test without usb connection. 1000 = 1 second.
Play with those a little while you take sensors in and out water to see if arduino reacts.

0
None
MortenB13kingofwoods

Reply 5 months ago

i wonder if my kit is faulty somehow, but thanks for your help :)