Watering the garden

Hi.

Some days ago, i was helping my girlfriend with a basic arduino demo for school, and that feeling i thought was dead, of electronics with programming, woke up again, so i decided to feed that feeling, and build a watering project for our garden...

I have never played with arduino before, just played with IC and digital electronics raw!

This will not be only some prototype, but i intend to put it to work with some pretty case :P So, this post is to gather opinions from you.

Due to garden dimentions, about 20m long, and diferent water needs, one side is less exposed to sun, i came up with this:

4 moisture sensors (capacitive) 3 ardunio nano (to load the program using USB) connected using RS485 wiring.

Slave1 with 2 sensors and water valve Slave2 with 2 sensors and water valve Master with LCD 20x4 or 16x2, 5 keys keypad, real time clock

The ideia behind 2 salves, is to reduce the distance between moisture sensors and arduino. The sensors will be berried under the grass and the arduinos will be on fixed on the wall.

Programming ideia: - Organize the sensors in groups (2 by ardunio) and calculate the average of group to open the water valve - The monitor will work on a configured time interval. ex from 6:00am to 7:00am - The master will have a menu, to set the clock, and configure interval, and groups. - The final fase will add some WIFI module with antenna, to connect with blynk. - The water will open if within the interval, some sensor min value is reached, and check every 5 minutes until interval ends or sensor max value is reached. Min and Max values are not defined yet.

This is my startup point. Please let me know your opinion.

EDIT: Link to github. The code is going slow, as I can only dedicate on or two hours a day to the project, and not every day.

C4m4l340: Hi.

Some days ago, i was helping my girlfriend with a basic arduino demo for school, and that feeling i thought was dead, of electronics with programming, woke up again, so i decided to feed that feeling, and build a watering project for our garden...

I have never played with arduino before, just played with IC and digital electronics raw!

This will not be only some prototype, but i intend to put it to work with some pretty case :P So, this post is to gather opinions from you.

Due to garden dimentions, about 20m long, and diferent water needs, one side is less exposed to sun, i came up with this:

4 moisture sensors (capacitive) 3 ardunio nano (to load the program using USB) connected using RS485 wiring.

Slave1 with 2 sensors and water valve Slave2 with 2 sensors and water valve Master with LCD 20x4 or 16x2, 5 keys keypad, real time clock

The ideia behind 2 salves, is to reduce the distance between moisture sensors and arduino. The sensors will be berried under the grass and the arduinos will be on fixed on the wall.

Programming ideia: - Organize the sensors in groups (2 by ardunio) and calculate the average of group to open the water valve - The monitor will work on a configured time interval. ex from 6:00am to 7:00am - The master will have a menu, to set the clock, and configure interval, and groups. - The final fase will add some WIFI module with antenna, to connect with blynk. - The water will open if within the interval, some sensor min value is reached, and check every 5 minutes until interval ends or sensor max value is reached. Min and Max values are not defined yet.

This is my startup point. Please let me know your opinion.

First : you are lucky to have a GF that has interest in such things. Second : I would offer to make smaller projects. 1 ) one Arduino with one sensors and output for relays. get this to work, add more sensors. 2) make a second, dupliace the first, make a seconds, third, foorth,etc. once you prove that you can get the parts to work, great. take a separete Arduino and add a display wiwth menu. I would offer to use an ESP8266 or ESP32 two reason : -faster/more memory, to drive the display -has built in WiFi Get everything to talk. be able to create a set point, say for the shady parts, send to the local Arduino controlling that valve. send the settings for one one in the sunny parts, As a note, you can also get weather on-line. predict rain and no water in the morning if it is to rain in the afternoon.

also, for a small garden, I would only allow one sprinkler to go on at a time. just to make sure that it has enough pressure to cover the area. Sounds like a fun project. I am in the middle of something similar. using 110VAC solenoid valves from dishwashers to allow pressure. using only 1 ESP8266, waiting on the RS485 for the captive soil sensors using relays for the high power to the solenoids. waiting on the encoder for the menu system. I have not started anything, only have half the parts.

Hi, thank you very much for your reply. I already put one ardunio powering leds... my weak is the electronics. I am a former C develper with good grades on 0's and 1's. eheh

This project is to build step by step to achive the final... i dont know how long it will take, but it must be finished by the summer... 9 months from now :P

The ideia of using the a nano as master, is to learn how to talk to wifi module on HW serial, and RS485 on SW serial ports. The current project, to my GF present at school, includes moisture and temperature sensors, an LCD 16x2, and 6 LEDS. As i dont use the TX and RX pins, i used a 74LD139 to decode the leds...

The fases i intend to follow: 1) put two ardunios talk with RS485 and then set the BUS for the three. I want this, to use the same cabe (CAT5 shielded) to transport power for the slave ardunios. This will avoid, i hope, one DC adapter on each arduino. 2) activate the water valve with relays or not. it will depend on the valve. i think will need to use some power driver with transistors to activate the relays. 3) study the EEPROM to store and load the configurations or some other persistence model that someone advise. 4) set the LCD and keyboard. Monitor information, write setup, manual open the valves, etc.. 5) set the WIFI on the master to connect with blynk.

I need ideias on wich will be a good and durable moisture sensor, if powered with 12V better. I found this ones, https://www.dfrobot.com/wiki/images/thumb/b/b4/SEN0193.jpg/300px-SEN0193.jpg

I need some advise, please. For this project i want the LCD to behave like this:

Light OFF, is the normal state. On some key pressed, the light should go to ON. Could it be to see what is on the screen, or to enter setup menu.

Should i check on loop for some key pressed or should i use some interrupt? What is your advise?

thanks

I would highly suggest you post a flow chart.

I expect you have more than one switch ?

typically in loop() you read all the inputs at the beginning of loop()

you can state that at any device pressed, you have a variable go high. if that goes high, start a timer.

if that goes high, turn on the display

after the last time any key is pressed, the variable goes low. turn off the display.

no need to use interrupts.

have you been able to get anything to work yet ? since you can buy almost every part you need, you should be able to get some parts working pretty easily.

Thanks for you reply,

i am waiting for the components to arrive. ETA: this week. in the meanwhile, i've been working on rs485 communication parts here

i will have 5 switches to setup and navigate the menu. up, down, left, right, select connected to analog pin...and i got it... if i some voltage on analog pin, e can light up the lcd :P

you ring the bell with this briliant question "I expect you have more than one switch ?"

Hi, new challenge on this project... I set the communications running, set the I2c Clock running, built the menu structure working, put the I2C Lcd 16x2 to work and build a 4 keys analogue keypad, which is almost working perfect :P

And this is the challenge, put it keypad working perfect.

This is the behaviour: At initial state, the lcd is light off. When press EnterKey, it should light up and show data/time. When press EnterKey again, it should shows the Menu, and navigate on the menu.

This is the tricky part. (debouncing is already being take care) Delay command is not a possibility in this program, as it is doing "many things at the same time"

I need to be very fast on keys or the loop will "think" i am pressing the same key several times, and the program will light up and enter menu with just one press. Or, when in menu, if i press UpKey or DownKey, it will move many items in one press.

Any ideas on how to avoid this behaviour? Detect a "NOKEY" between two keys?

look at the button sketch that is part of the IDE

if you press the button, you can add an if()

if(button == HIGH) { count ++ ; // increments by 1 if (count =>6) { count = 0 } ; // reset to 0 if it goes too high }}

if count == 0 then normal reading if count == 1 menu page 1 if count == 2 menu page 2

and so on.

Hey there! sounds like a fun project!

I am currently building something similar for automating a greenhouse, doing aquaponics as well as other stuff like that.

here is my two cents -

-as simple as you make it seem in your (correct) logic break down, this is not a simple project. - break this project down into these steps - read sensors,compute actions on inputs, take actions on sensor values, display those values of interest (on say an lcd), then log if needed those values.

if you try to do it all at once, you start yelling at your GF over the cybernetic timing of tomatoes! no good!

imo - getting sensors to read, the right way is a big part of this sort of thing. so many libraries. so many methods, wiring issues, etc etc. getting a sensor to read is a BIG THING!

you can build your logic - with no senors working. if you have an idea (like your clearly do) - then can create a program with only serial.print outputs for conditions - and completely test your logic - before you do any sensor work.

lastly - once you have overcome sensor read issues - and logic issues - actions issues are IMO -the easiest!

usually - you either change another var, or for real world stuff - you flip the pin hot on a relay that turn something on for a period of time/condition that you have already figured out with your logic testing from previous step.

double last - display it on a LCD or other. I will tell you - as of right now, in my greenhouse program - the UI and config in the LCD part of the program is LONGER and more COMPLEX than anything else - like reading, computing, or acting on values. GL!

Thanks for you words!

The most stressing part for me on this project, is the lack of time, and mind-set change.. With only a couple of hours a day, and coming from a different programming logic (C# on web applications 8 hours a day), the owl thing is a big challenge. My c++, is completely rusty. But most of the "small pieces" are tested, except for the SD card and WIFI. The menu navigation is working, the keypad too. I am redesigning the communication class, as some timeout checks are interfering with keypad.

The infinite loop is a big challenge ehehehhe i can send the code if someone ask for it. It is not complete yet and have a lot of commented stuff :D

I am certain that the "code pattern" i use, is not the standard one, but again.... my c++ is completely rusty.

Well...post some code up when you can. daves advice the best. Chunk this project up. You can spend more time on sensors, wiring and libraries than getting the big picture logic to work.

Also...many a ways to work with infinite loop. A lot of my stuff is timing based. Also..a lot of my stuff doesn't need to be checked/done 10 times a second. We can help you there, just post up your first attempt.

Maybe the watering logic using "dummy" sensors and serial print outputs.

Hi, here goes an update. Starting the project for the third time.

I am such an organized person I lost my code two times.

Finally got solved the problem os SoftwareSerial not working inside my class. It was a buffer overflow problem with debug to hardware serial.

At this point I have a "multitasking" program which runs: a blinking RGBled on idle state and when waiting for a slave response. A keypad with a Keyup callback. A serial communication, and a clock with a callback, all running in "parallel".

I think this is it....

I'll be posting the code as soon as it advance a little more on menus...

Updated the first post with a link to the code.