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

Any updates for our project :slight_smile: ? Don t want to bother you, but yo know how it is when you are waiting something you really desire :slight_smile:

I’m so sorry, I’m in bed already. I worked late so there was no time for this project. :worried:

It s ok,we have time.This weekend i will go to my grandmother house,and there is no phone or internet signal…i wish u a great weekend.And if i finish there in time,i will try to come home earlier.

This is quote odd. Are you sure you have the voltage and ground lines correctly connected on your moisture meter? The values should be from 0 (completely dry) to 1023 (completely moist):


Hi, I disassembled the circuit and assembled it in place. But the result is the same. It says it is dry when it is in the mud and wet when it is in the dry soil.I replaced the old sensor with a new one that gives me higher values ​​than the old one. But it also says that it is dry when it is in wet soil and wet when it is in dry soil…The maximum moisture on new sensor is 1014 an minimum moisture0293

I have poured some water over the already wet soil and given lower humidity values, ​​it dropped below 300.Now moisture is 290
I tried to reverse the sensor gnd with vcc, but the lcd voltage decreases. So I think they are well put

1 Like

Okay, I’ll just change the code to work with that.

Thank you very much. I look forward to the new changes.

I’m sorry you’ve had to wait so long. I’ve been very busy at work and spent some time helping my son with some code as well.

The parameters for operation are defined in these lines of code near the top of the program. I’ll explain each one below.

// Operating parameters
#define LDR_MAX_LIGHT 800
#define WATERING_TIME_MS 3000
#define POLL_DELAY_MS 60000
    This should be the LDR (light sensitive resistor) value that indicates it’s night time.

    Set to 400 now, but this should be the moisture level you want the system to target/aim for

    I’ve set this to 800, but you should set this to the level the moisture meter indicates when you would like it to add water even if it’s day time.

    This time (in milliseconds) controls how long to apply water for. It’s how long the relay is kept on for which only you can tell from how much water your pump transfers in the time. It’s 3000ms now (3 seconds).

    This time (in milliseconds) controls how long the system sleeps after checking the soil and applying water if needed. I set to 1 minute (60000) for now but it could be much longer really (5 minutes, 15 minutes, etc.).

I’ve made a change to the code so that the logic will apply correctly for the daytime watering based on the target and danger moisture levels. So if you get a different sensor that reports higher values for more moist soil, you only have to alter the operating parameters.

1 Like

thank you very much, now I will try the code with the new changes and let you know what happened.

1 Like

My friend, i modified the code as you told me …the problem is the same…the sensor indicates too much water in a dry soil and too little water in a wet soil. I am sorry that this become an issue but I really appreciate your help.

And I replaced the MIN with DANGER in the code …as I understood from what you ve told me …

Sorry, just now I noticed that the code was also changed on github. I copied it to the arduino and now it irrigates even if the soil is dry or wet. The values ​​shown are the same, when the sensor is in wet soil; moisture 0353 watering, when it is in dry soil; moisture1006 watering.This with the new sensor.
With old one in wet soil;moisture0338,watering,in dry soil;moisture0572,watering.I prefer the old sensor, i corrodes harder :slight_smile:

Thanks for the detailed explanations about how I can change the values ​​according to the need :slight_smile: They will really help

Oh dear. I’ll double check the code tonight to make sure it works as I intended.

1 Like

You discovered a bug in my code, thank you!

I’ve updated the code and tested the logic in another program running through the different sensor values to check that it waters when it should. Please take a fresh copy of the code off Github: https://github.com/bernhard-hofmann/circuito.io-4045/blob/master/AutoWater.ino

1 Like

Thank you a lot my friend!I will make the test now,and let you now what happend :slight_smile:

I made the test and now it works :slight_smile: Even if It shows that is dry when is wet and wet when is dry,(i say that because the values are lower when is wet and higher when is dry), but irrigates when in fact it s dry :slight_smile: .Probably you modify the cod to work like that ,so i think that it will make the job :slight_smile: Thank you a lot. The three buttons are working now,or they will in the future?And how i can use those buttons ,if they are working?If you remember,i need a air humiditi sensor too ,If i didn t ask too much already :slight_smile:
Thank you a lot for everything, you are the best !

1 Like

LDR light works I think backwards, when the light is on it says LDR 0163 (and around this value) and when the light is off, LDR 0040 (and around this value).But i think that if I change the value (800 with 50) it would be the correct modification to make the light resistor work properly :slight_smile: ?

That sounds correct to me (less light = lower values) and changing it to 50 would be good. I’ll do the same in the GitHub code so that you don’t lose changes if/when you replace it.

Thank you very much :slight_smile: you are right as always.