I need help in creating the program of an automatic irrigation system with lcd

****heloo friends! I’m at just a beginner, didn’t do any arduino code.My problem is that I don’t have time to wet my grandmother’s greenhouse (and at 91 years old she can’t even). so I hope to find some understanding and help in making the code for grandmoder s automated irigation system!I have an arduino uno,a iic/i2c display,one channel relay,moisture sensor,5v waterpomp. I can do the sketch with(circuito.io)but the program is impossible for me:(… If anyone can help me with the code for the described irrigation system would be huge for me:)

Hello and welcome

Could you share the link to the circuito circuit please?

It would also be good to hear your thoughts on how it should work. (Just in plain English, not code.)

Depending on how far away you are, it might be useful to include a WiFi module so that the Arduino can report back to you things like the current moisture level and when it waters the plants.

Hello and thanks for the quick response:)The truth is that I do not have a scheme, but only noticed that it can be done with the circuito application.Sorry if I created confusion.
The easiest thing for me would be if I say what components I have and based on them to make the code and sketch.I would not know which of the components I have would be more suitable,and if i need something more,i am a beginner,so please be patient with me:)
The system I wanted and designed in my head, in English as you vrey beautifully said:)
1 measures soil moisture several times (5-7times is ok?) and then averages and displays it on lcd
2 then pause for a minute(or less if u consider) and start the measurements again
3 when the average of the soil moisture measurements drops below 35 percent (or 30 as you consider)to transmit to lcd that the humidity is 35(30) percent and the irrigation begins for 5seconds( 3,4,7 secondes if u consider it) (it can display other text you prefer)
4 after measuring again the soil moisture and if it has not reached the desired humidity (80-90 percent for example or what you conside it will be better) to display on the lcd that,and the irrigation starts again for 5seconds(or3,4,7seconds as you consider)and repeat until the soil reaches the desired moisture.
5 it would be preferable to use a 5 volt power supply. Only one power supply to the arduino and the pomp not two, but if cannot be done with one power supply,then 2 is ok :slight_smile:
6 I would love it if It could somehow irrigate when it is night because it is not good to water the plants during the day
7 If the soil moisture is below 25 percent if we determine that at 30 percent irrigates at night,to irrigate even if it is day but if is possible just one time for 10 seconds(but if is not posisible,is ok to irigate until it reaches 80,90 percent(and also dsplay this if is possible).
The cruel truth is that I’m even less than a beginner, I think it would be best if someone experienced had the good will to help me with the scheme and the code
I really like the idea with wi fi,it is extraordinary, but my grandmother lives 27 km away and I could not get there in time to irrigate.I’m already embarrassed because I think what I want for my grandmother is already a complicated project, and someone should lose their time helping me.But i promiss i will send him pictures of my 91 years old happy grandmother:)
I promised that I would say what pieces I have for this project.
1 Arduino uno r3 Armega328P
2 a 1 channel 5v relay, and a12 v relay but i prefer the 5 v power
3 Breadboard
4 lcd 1602 iic/i2c and a lcd 1602
5 soil misture sensor(i have a capacitive soil moistur sensor and a humidity mositure sensor with modul)
6 12 and 5 volt water pomp(not servo normal )
7 L293D motor driver shield
8 10 k potentiometer
I don t know if i need all these or more,but if i need more i ll take what i need
I managed to make myself undestood:)?This can be a bit simplistic if it does his job well,anything close if it does it job well will be perfect :slightly_smiling_face:
What do u think about what i have in mind?

Thanks for your time and just in case here is my email [email protected]

I forgot, the water comes from a large barrel, I also have a water level sensor but it is not necessary if it complicates much.
I thank you again,i hope i will have hom to sen my happy grandmother s pictures :slight_smile:

Sorry I’ve been away and really busy with other things. I’m keen to help you and will get onto this very soon.

You’re right in wanting to make this as simple as possible so let’s leave the WiFi for now. You can always add it later.

Just so that you know, I’ve heard that the moisture meters eventually corrode and fail so you should keep that in mind when you build it so that they’re easy to replace.

Other than that, I’ll get started on a circuit now and then write some code.

I’m not sure what type of pump you have. I’ve chosen a pump that doesn’t get any parts wet so it should last a long time. In the following circuit you have the Uno for control, a real time clock (RTC), the pump, and a moisture sensor. You didn’t say what kind of display you wanted to use so I’ve opted for a simple and cheap LCD.

You could add multiple moisture sensors and multiple pumps if different plants have different watering needs but for now, let’s keep it simple.

https://www.circuito.io/app?components=9442,11021,13322,113323,417986,898128

Please tell me whether these components are fine or whether you’d like to use different ones so that I can start on the code.

Hello and thanks again for the quick response. Thank you for telling me that the humidity sensor does not last long. I will follow the advice and I will do it so I can change it easily.
Couldn’t go without a real time clock, with a relay or a motor control board? Preferably it would be with a relay, I think it’s simpler, right?

I have a single channel relay and a motor control board, I would prefer to be either relay or motor control board, but with relay I think it’s easier .As the water pump I have a normal 5 volt but I also have a normal 12 volt aquarium pump.

I can’t wait to start “building”. Thank you very much, it means a lot to me

The RTC was added so that it can water at night rather than during the day. I’ve removed it and opted for a MUCH cheaper LDR (light sensitive resistor) that can be used to determine whether it’s dark or not which will actually work better because there’s no battery, no need to set the time, not sensitive to daylight savings clock changes, etc. YAY!

I’ve also removed the pump and just added a relay. It’ll be up to you to wire the pump to the relay and we’ll treat that as external to the system.

I’ve added three mini push buttons so that you can have a menu and be able to control the menu and make selections. These will be useful for testing the system when you’ve built it and when you install it as well.

https://www.circuito.io/app?components=97,97,97,9088,9442,11021,13322,417986,3061987

Are you happy with these components?

Yes the circuit is perfect! You made my day happy.Thank you very much, you are wonderful!

What you can do now is download the sample code that’s generated. The way to do this is to download the ZIP file with the button at the bottom of the code file list:

image

After you unzip the files to a local folder, you should be able to open the “Firmware.ino” file in the Arduino IDE. Have you downloaded and installed that yet? Do you want a guide to transferring the code to the Arduino or have you managed that already? Sorry if that’s insulting, I only ask because you said you’re an absolute beginner.

There’s also a project guide that has a “Wire” section that walks you through the wiring step by step: https://www.circuito.io/static/reply/index.html?solutionId=5e36dd40e70009003069c1cb&solutionPath=storage.circuito.io

I’ve taken a copy of the code and renamed it to “AutoWater” because “Firmware” is just so generic it’s boring. :smiley:

I’ve also created a Github repository to track the changes I make to the code to satisfy the requirements you’ve explained: https://github.com/bernhard-hofmann/circuito.io-4045

I’ll try remember to comment the code as much as I can, but you’ll be able to track every change I make and ask why I’ve done this or that if it’s not clear.

I don’t have the components you have, so I’ll be working blind. I don’t even have an Uno! I’ve only ever had an Arduino nano, which I might be able to test some of this code on. So please be patient if things don’t work. I’m also starting a new job tomorrow so I don’t know how much spare time I’ll have. I’m in the UK so I’m guessing two hours behind you if you’re in Romania (a guess from your name).

#include <Switchable.h>
#include <LiquidCrystal_PCF8574.h>
#include <Relay.h>
#include <AnalogReader.h>
#include <LDR.h>
#include <Button.h>
#include <SoilMoisture.h>

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}

heloo I downloaded from git hub. But is all the code?

Yes,i am from Romania u guessed well:)

Yes, the Github project should include all the necessary code.

I’ve just pushed a new version that changes the Serial menu to use the LCD and show the values it reads from each sensor and flips the relay on and off. It’ll keep doing this while running so that you can test your circuit and fiddle with wires, buttons, the LDR, moisture sensor, etc. if you like.

please help.i don t know wat to do.after i downloaded into arduino the program conteins only #include <Switchable.h>
#include <LiquidCrystal_PCF8574.h>
#include <Relay.h>
#include <AnalogReader.h>
#include <LDR.h>
#include <Button.h>
#include <SoilMoisture.h>

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}