Easiest Arduino Smart Plant Watering

36K148102

Intro: Easiest Arduino Smart Plant Watering

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.

62 Comments

Has anyone had any luck as to getting a light sensor installed (to determine if sun is up or setting), possibly a way to check stats online (connecting it to home wifi and giving it it's on webpage/server or whatever it needs), rain sensors ( to determine whether or not to even turn on pumps), any other neat little ideas out there?
does anyone have a model of the 2.0 in a stl file so I can 3d print an enclosure?
Here is an updated version of the Elecrow Plant Watering System with the single board Arduino Leonardo. It is modified to read moisture sensor status and manually enable/disable pump via ESP8266 via MQTT. It will also read water level with HC-SR04 ultrasonic sensor to disable pump when water level is low:
https://github.com/rfrancis97/elecrow-watering-kit...


When I try to upload the software, I get the following error

WArduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino Leonardo"
In file included from C:\Users\Dell\Desktop\watering_kit (8)\watering_kit\watering_kit.ino:2:0:
U8glib.h:42:22: error: clib/u8g.h: No such file or directory
compilation terminated.
exit status 1
clib/u8g.h: No such file or directory
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

What do I need to do?

Thanks
I flashed the code on this tutuorial via the directions it gave (I'm new to Arduino), and the pump and valve are infinitely open.

I need to address that and I have a few more questions.

What part of the code defines how long it should be open? I know Matlab but C is new, so I can sort of read it. I notice that the codes comes with a lot of stuff commented out. Am I supposed to uncomment this?

Also what will happen if the pump runs dry long enough? Is it a fire hazard?

What does the % translate to that is shown on the display. I know its moisture, but is it X % of a predefined moisture value?

I also tried the code further up in the comments and it runs the same. Valve stuck open, runs indefinitely!

Thanks! Any help is appreciated, I'm going on a two week honeymoon and 3 months and I need a really robust system to keep my plants alive. Any help is greatly appreciated!


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?

Did you ever succeed with programming the millis(). I too am trying to get away from delay() as I'm taking temperature readings in the sketch as well.
millis are easy to use: - just think that every time main loop starts, certain amount of millis(read milliseconds or time) are added to the previous loop, and lets say if you elapsed period(or want some action to happen at certain time, for example to turn LED on after 5 seconds), you have to state in the code to switch led when millis reach 5sec(5000 ms) and then reset period or change LED status, depending of what you need
I have a smart pump board v2.0! how does it work? what's the code?

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

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.

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

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);

}

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.

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!

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 :)

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!

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

//Water correct plant function

void waterPlant(int x) {

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 ?

More Comments