OpenSprinkler › Forums › OpenSprinkler Unified Firmware › Flow Sensor Working › Reply To: Flow Sensor Working
Attached is the two files modified for the flow sensor SW mods using the rain sensor input and an ISR to trigger on the rising edge of the sensor pulses. It seems to work pretty well so far.
I tried to put my initials in the comments // RAH so that you could easily find the changes. Essentially the main.cpp is changed to add the ISR, update the LCD display if GPM is measured, and added to the write_log function so it writes the GPM as an additional field in the normal log file.
To calculate GPM for the LCD display it just takes the last pulse minus the previous pulse time to determine how long it was for one gallon and calculates GPM. For the logfile it calculates the average GPM starting after 90 seconds of the valve being on (the max time it should take to fill the line typically), until the valve is shut off, for greater accuracy in measurement.
The opensprinkler::set_station_bit was modified so that when a valve turns on, we clear some variables, and when we turn off the station, we calculate the logfile gpm average, which later gets written to the logfile.
Any questions or suggestions please let me know.
As for how to detect leaks, not implemented but brainstorming here: need to detect slow leaks which would look like a certain # of pulses every hour (i.e. no hour in 24 hours without some flow rate pulses). For a faster leak, for 60 consecutive minutes in the day, each minute had at least one pulse with no valves on. So if you were washing your car, it wouldn’t detect an error as long as at least one minute in 60 minutes there was no flow.
Perhaps the harder thing will be to somehow get a text or email from the OS without running RPi etc.