Hello All!
I have a pretty ambitions project that I have been expanding on and constantly adding too for about a year now, and I am hoping to find some assistance with 1) optimizing my code and 2) some thoughts on moving forward and creative ways that I can expand my automation to some of the new projects that I have coming up or start doing a SCADA integration.
My code is pastebinned here: TFACC - Pastebin.com
Ok so the layout is pretty much the start of things i guess:
Arduino Mega 2650, currently the ONLY controller in the project
I have an 8 chan 5 VDC relay board on the main control panel.
I have a remote junction box with an LCD backpack, 3) 12 VDC LED's, a MCPB switch, and a three position switch installed in.
Inside the remote JBox I also have a 16 chan relay board mounted and most of the terminations run to terminal blocks.
I also have another remote PB station, its an AB fiberglass outdoor explosion proof box with a MCPB in it and a 12 / 24 VDC sonalert
The 12 VDC source that I am using is just a cheap switching power supply from amazon.
D1307 RTC (battery eater)
The Current Automation Scope
What is does well: Timed functions work quite well. The system calculates the time of sunrise and sunset each day, Then calculates a bunch of other variables from those times. Then the controller runs functions based on those calculated times: For example, The chicken coop door is opened and closed by a 12 V 24 inch stroke linear actuator. At 1 hour after sunrise the door is opened and stays open all day. At 40 mins after sunset the door closes automatically locking the chickens away for the evening.
There is a 12 V controlled deer feeder that throws scratch feed for the chickens 15 mins before the door closes, gathering all the chickens and guineas right by the door so that we can usher them inside.
There is a 12 V sprayer pump that sprays cooling mist on the chicks and the goats everyday during the summer.
The 120VDC overhead lights in the barn are kept on every night to make sure the chickens receive a calculated 14 hours of light based on the number of daylight hours they get naturally and determines what time the lights should go off.
What it doesnt do or do well yet (alot of this could be wiring / hardware / has not been programmed.)
Scan time: My code needs a serious look over to determine if there are faster or easier ways to do things. Current loop time is almost 4 seconds. There is a 1K MS delay that is in the loop for the timealarms library but 4 seconds is a looooooog cycle.
It doesnt deal with DST and Non DST well. I have to reset the time on the thing every 6 months.
It does not have any sort of display / monitoring unless I tie in my laptop.
It does not do any measurement or alarming.
I am building a duck pond this weekend and i would really like to be able to monitor water conditions. I would like to be able to monitor the levels of food stores in the food bins and give me a signal or alarm when its getting low.
The duck pond and the filtration system monitoring is going to also be part of an aquaponics ebb and flow system I want to tie in. That is going to add some PID controls.
I know this thread is like super long. But I am just trying to lay it all out for any suggestions that yall might have.
The code is posted for anyone that might want to gaze over it: TFACC - Pastebin.com