Well Pump Control - Raspberry Pi Forums
hello,
building system remotely control pump. pi set @ remote water tanks , programmed sense level tanks @ (using 3 float switches) , trigger pump on , off appropriately. have 3 indicator lights triggered indicate current tank level. after sensing change, pi activates radio link pump , sends dtmf tone received dtmf relay board switching of pump , indicator lights.
problem.... using event detect functions sensing , triggering. need way script auto detect current tank level , act appropriately. example... after power failure, need pi reboot, read sensors , update well's level indicators , pump control.
redundancy name of game here. new programming there clean done here.... biggest problem having auto sensing on start up.
thanks!
building system remotely control pump. pi set @ remote water tanks , programmed sense level tanks @ (using 3 float switches) , trigger pump on , off appropriately. have 3 indicator lights triggered indicate current tank level. after sensing change, pi activates radio link pump , sends dtmf tone received dtmf relay board switching of pump , indicator lights.
problem.... using event detect functions sensing , triggering. need way script auto detect current tank level , act appropriately. example... after power failure, need pi reboot, read sensors , update well's level indicators , pump control.
redundancy name of game here. new programming there clean done here.... biggest problem having auto sensing on start up.
thanks!
code: select all
import time import rpi.gpio gpio import pygame subprocess import call gpio.setmode(gpio.board) # 100% pin gpio.setup(11, gpio.in, pull_up_down=gpio.pud_up) # 2/3 pin gpio.setup(13, gpio.in, pull_up_down=gpio.pud_up) # 1/3 pin gpio.setup(15, gpio.in, pull_up_down=gpio.pud_up) # kill gpio.setup(7, gpio.in, pull_up_down=gpio.pud_down) def my_callback(channel): if gpio.input(11): print ('tank full - draining') gpio.setup(16, gpio.out) time.sleep(4) gpio.setup(18, gpio.out) time.sleep(1) call(["aplay","/home/pi/desktop/dtmf/3off.wav"]) time.sleep(2) call(["aplay","/home/pi/desktop/dtmf/3off.wav"]) time.sleep(1) gpio.setup(18, gpio.in) gpio.setup(16, gpio.in) time.sleep(3) else: print ('tank full') gpio.setup(16, gpio.out) time.sleep(4) gpio.setup(18, gpio.out) time.sleep(1) call(["aplay","/home/pi/desktop/dtmf/3on4off.wav"]) time.sleep(2) call(["aplay","/home/pi/desktop/dtmf/3on4off.wav"]) time.sleep(1) gpio.setup(18, gpio.in) gpio.setup(16, gpio.in) time.sleep(3) def my_callback2(channel): if gpio.input(13): print ('tank 2/3 , draining') gpio.setup(16, gpio.out) time.sleep(4) gpio.setup(18, gpio.out) time.sleep(1) call(["aplay","/home/pi/desktop/dtmf/4on2off.wav"]) time.sleep(2) call(["aplay","/home/pi/desktop/dtmf/4on2off.wav"]) time.sleep(1) gpio.setup(18, gpio.in) gpio.setup(16, gpio.in) time.sleep(3) else: print ('tank 2/3') gpio.setup(16, gpio.out) time.sleep(4) gpio.setup(18, gpio.out) time.sleep(1) call(["aplay","/home/pi/desktop/dtmf/2on.wav"]) time.sleep(2) call(["aplay","/home/pi/desktop/dtmf/2on.wav"]) time.sleep(1) gpio.setup(18, gpio.in) gpio.setup(16, gpio.in) time.sleep(3) def my_callback3(channel): if gpio.input(15): print ('tank 1/3 , draining') gpio.setup(16, gpio.out) time.sleep(4) gpio.setup(18, gpio.out) time.sleep(1) call(["aplay","/home/pi/desktop/dtmf/1off4on.wav"]) time.sleep(2) call(["aplay","/home/pi/desktop/dtmf/1off4on.wav"]) time.sleep(1) gpio.setup(18, gpio.in) gpio.setup(16, gpio.in) time.sleep(3) else: print ('tank 1/3') gpio.setup(16, gpio.out) time.sleep(4) gpio.setup(18, gpio.out) time.sleep(1) call(["aplay","/home/pi/desktop/dtmf/1on4on.wav"]) time.sleep(2) call(["aplay","/home/pi/desktop/dtmf/1on4on.wav"]) time.sleep(1) gpio.setup(18, gpio.in) gpio.setup(16, gpio.in) time.sleep(3) #raw_input("press enter when ready\n>") gpio.add_event_detect(11, gpio.both, callback=my_callback, bouncetime=30000) gpio.add_event_detect(13, gpio.both, callback=my_callback2, bouncetime=30000) gpio.add_event_detect(15, gpio.both, callback=my_callback3, bouncetime=30000) try: print('waiting input...') gpio.wait_for_edge(7, gpio.rising) print('program killed.') except keyboardinterrupt: gpio.cleanup() finally: gpio.cleanup()
this problem has been solved zillions of times... without raspberry pi(s)... take @ this:
http://www.next.gr/microcontrollers/805 ... 25613.html
try avoid using moving parts. avoid using interrupts , callbacks. make simple event loop starts running pi boots , runs avery few minutes (30) fired off crontab entry. have pi scan sensor mcu (use pyboard micro python, or other) , log, lights, signal whatever... go sleep... pi free other things (not dedicated pumphouse).
http://www.next.gr/microcontrollers/805 ... 25613.html
try avoid using moving parts. avoid using interrupts , callbacks. make simple event loop starts running pi boots , runs avery few minutes (30) fired off crontab entry. have pi scan sensor mcu (use pyboard micro python, or other) , log, lights, signal whatever... go sleep... pi free other things (not dedicated pumphouse).
raspberrypi
Comments
Post a Comment