The code below shows a simple counter program that will increment a counter variable every time pin 1 on the digital IO bus is pulled high to 5V.
from __future__ import absolute_import, division, print_function, \
print("Failed to import ExpanderPi from python system path")
print("Importing from parent folder instead")
"Failed to import library from parent folder")
Main program function
# Create an instance of the IO class called iobus.
iobus = ExpanderPi.IO()
# Create a counter variable
counter = 0
# Set all pins on the IO port A to be inputs with internal pull-ups disabled.
if (iobus.read_pin(1) == 1):
counter += 1 # increment counter
# wait for pin to go low again
# sleep 200ms before checking the pin again
# print the counter value to screen
print("Count: " + str(counter))
if __name__ == "__main__":
You may need to add a 10K resistor between pin 1 and ground to pull the pin low between pulses, otherwise it could be left in a floating state where it may cause false triggers.
Depending on how fast your flowmeter pulses you may need to decrease the time.sleep(0.2) value inside the while loop to allow more than 5 pulses per second.
You are welcome to post your temperature monitoring sample on this forum, I am sure other forum users will find it useful.