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 TARGET_MOISTURE_LEVEL 400 #define DANGER_MOISTURE_LEVEL 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.