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

Does anything appear on the LCD?

And is the LCD you have I2C? (Just four wires)

i have exactly the elements you showed in the circuito sketch and the I2c with 4 wires. now i am assembling the circuit but there is nothing on the serial monitor yet. It will appear directly on the lcd after the circuit will be done ?

If nothing appears, you might have to change the address as explained in the comments starting on line 18:

// There are several different versions of the LCD I2C adapter, each might have a different address.
// Try the given addresses by Un/commenting the following rows until LCD works follow the serial monitor prints.
// To find your LCD address go to: http://playground.arduino.cc/Main/I2cScanner and run example.
#define LCD_ADDRESS 0x3F
//#define LCD_ADDRESS 0x27

You could change it to be like this to try the other address:

//#define LCD_ADDRESS 0x3F
#define LCD_ADDRESS 0x27

Yes, only on the LCD. I can write to the serial monitor as well if you like.

I’ve made a change to write to the serial monitor as well so you can try the latest version. You should be able to just go to this link, select all the text, copy it, and replace the code in the Arduino IDE with that.

https://raw.githubusercontent.com/bernhard-hofmann/circuito.io-4045/master/AutoWater.ino

it s ok, don t write it for the serial monitor. As i already told you, i am a beginner so i thought if it doesn t appear there ,it might be a problem . In about 10 minutes i will do the circuit and i ll write back

i did the circuit, the lcd is on but still nothing appears on it. From time to time , the relay, clicks

Do you see anything on the serial monitor?

Again, you might need to swap the LCD address as described above.

Still nothing on the serial monitor.i change the adres in a minute

Did you copy the latest code over your current code?

yesssssssss…finally it works, i am so happy …thank you my friend!!! the relay is still clicking…is this a problem?

i done the circuit with the capacitive soil moisture sensor v2.0 with 3 wires like the one in the circuito sketch, just it has 1 leg, not 2 like yours. Could be this a problem ?

The relay will click as part of the test. It gets turned on and off quite quickly during the test.

I don’t know much about the moisture sensors I’m afraid, but I doubt the number of legs will be an issue. What I need from you is what the serial output data about the values from the sensor when it’s dry, and when it’s in damp soil.

i should understand that at some point te relay will stop cliking .
but the 3 buttons what are they for?
to make the test i must put the sensor in water, yes?

is testing again and again,never stops

Put the sensor on wet soil. I don’t think pure water will be the goal.

You can see the state of the buttons of you hold them down during the diagnostics. They’re not used yet, but will be used later to let you modify settings. You can ignore them for now if you like.

See above:

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.

i put the sensor in soil,but still the relay clicks

Just unplug the relay for now.

I’m off to bed. Please send through a copy of the serial output when you’ve had the moisture sensor in moist soil and when it’s dry.

Good night, thank you for all your help. Talk to you tomorrow, if you have time for me .

I still need the sensor values from you to put into the program so that I can write the code to decide when to turn the relay on.

My thinking is it should do this (in a loop, over and over)

  1. If it’s dark and the moisture level is below M (need your value here) then turn the pump (relay) on for N seconds.
  2. Wait for X seconds. (Let’s the water soak into the soil to prevent over watering).

I think X could be 30 seconds, or even 60, but I’m not sure what M should be which is why I need to know what your serial monitor is showing for the moisture value when it’s dry and when it’s in moist soil.

I’ll start with a small N and you can fiddle with that number until the pump pumps a suitable amount of water.