I've been struggling to get interrupt to work on my 5b with a water flow sensor. Any suggestions or help is appreciated.
Here's what I've tried and validated so far:
Hardware:
The flow sensor signal wire is connected to wiringpi pin 2, which is physical pin 7, gpio pin 54
I've put in a pull-down resistor between the gpio pin and GND
I've confirmed with a multi-meter that the signal line has a voltage of 0 when the sensor isn't spinning.
I've confirmed that "gpio read 2" shows the pin as 0 in that state
I've confirmed that the signal line voltage peaks to around 1.5 vdc when the sensor is spinning.
I've confirmed that "gpio read 2" shows the pin pulsing in that state between 1 and 0.
Docker:
I've exported gpio 54 and set it to in
The container runs in privileged mode with volumes to all the important bits mapped
Python:
I wrote a stupidly simple script just to increment a counter and print its value when the interrupt is called
wiringpi correctly reads and sets values for all the other gpio stuff I'm doing on the board (temp sensors and relays), it's only the interrupt job that isn't working
Docs for above assertions:
Python script:
import wiringpi
import time
# The pin number to which your sensor is connected
SENSOR_PIN =2# Initialize wiringpi
wiringpi.wiringPiSetup()# Set the pin to input mode
wiringpi.pinMode(SENSOR_PIN, wiringpi.GPIO.INPUT)# Initialize the counter and the tick
counter =0def count_pulse():global counter
counter +=1print(counter)# Set the interrupt to be triggered when the pin's voltage rises from LOW to HIGH
wiringpi.wiringPiISR(SENSOR_PIN, wiringpi.GPIO.INT_EDGE_RISING, count_pulse)# To keep the script runningtry:whileTrue:
time.sleep(1)except(KeyboardInterrupt,SystemExit):print(f'Total pulses: {counter}')print('Exiting...')
(I realize the port mapping between the docker compose and the dockerfile are not aligned. That's on my TODO list, but isn't a factor for this problem. I'm testing by exec'ing into the running docker container after build and executing the test script)
GPIO Interrupt not recognized on OP-5B
in Rockchip
Posted · Edited by thatsimonsguy
I've been struggling to get interrupt to work on my 5b with a water flow sensor. Any suggestions or help is appreciated.
Here's what I've tried and validated so far:
Docs for above assertions:
version: '3' services: squirtgun_test: image: squirtgun_test:latest privileged: true volumes: - squirtgun_config:/usr/src/app/squirtgun/config - squirtgun_db:/usr/src/app/squirtgun/db - /etc/orangepi-release:/etc/orangepi-release - /etc/armbian-release:/etc/armbian-release environment: - REGISTRATION_OTP=#### - PARENT_BASE_URL=#### - ZONE_RELAY_PINS=5 - TRANSFORMER_RELAY_PIN=7 - TEMP_SENSOR_PIN_1=8 - TEMP_SENSOR_PIN_2=9 - FLOW_SENSOR_PIN=2 - DEBUG_NO_MTLS=True ports: - "5000:5000" volumes: squirtgun_config: squirtgun_db:
(I realize the port mapping between the docker compose and the dockerfile are not aligned. That's on my TODO list, but isn't a factor for this problem. I'm testing by exec'ing into the running docker container after build and executing the test script)
Cheers and thanks!