Flow Sensor - ArtTHEbard/Hydro-Pi-nics GitHub Wiki
Configuration
This sensor is used to measure the flow of water running through the system and to ensure that water is constantly flowing, which is crucial to the operation of the hydroponic system.

The following code was used to initially test the sensor and to pipe the data up to ThingSpeak:
#!/usr/bin/python
import RPi.GPIO as GPIO
import time, sys, os, httplib, urllib
FLOW_SENSOR_GPIO = 14
GPIO.setmode(GPIO.BCM)
GPIO.setup(FLOW_SENSOR_GPIO, GPIO.IN, pull_up_down = GPIO.PUD_UP)
global count
count = 0
def countPulse(chennel):
global count
if start_counter == 1:
count = count+1
GPIO.add_event_detect(FLOW_SENSOR_GPIO, GPIO.FALLING, callback=countPulse)
key = "ZN6R5LVF4C606H6N"
while True:
start_counter = 1
time.sleep(1)
start_counter = 0
flow = (count / 7.5)
t = time.localtime()
current_time = time.strftime("%H:%M:%S", t)
params= urllib.urlencode({'field1':flow,'key':key})
headers={"Content-type":"application/x-www-form-urlencoded","Accept":"text/plain"}
conn = httplib.HTTPConnection("api.thingspeak.com:80")
try:
conn.request("POST","/update",params,headers)
response=conn.getresponse()
print("The time is: " + current_time + " The flow is: %.3f Liter/min" % (flow))
print(response.status, response.reason)
data = response.read()
count = 0
time.sleep(5)
conn.close()
except KeyboardInterrupt:
print("Done")
GPIO.cleanup()
sys.exit()
After seeing that this code was successful, run the Python script using python water_flow.py. The terminal should show the reading and a HTTP 200 OK Message. The data should be displayed on ThingSpeak.
Mycodo Integration (DEPRECIATED)
In order to integrate the sensor into the Mycodo Software, we navigated to the Data -> Inputs section and selected Generic Hall Flow Meter from the drop down menu.
We used the following settings according to the flow sensors data chart.
Once that configuration was complete, I went to our dashboard and added a new Gauge (Solid) widget to the dashboard. I entered the following settings into the widget configuration.
Once this was complete, my dashboard widget accurately displayed the sensor data coming from the flow sensor.
