I’ve ran into the following problem trying to use the RPi.GPIO edge detection functions with a BPi M2 Berry:
First, some informations of the OS:
[email protected]:/home/pi/RPi.GPIO_BP# lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 8.0 (jessie) Release: 8.0 Codename: jessie [email protected]:/home/pi/RPi.GPIO_BP# uname -a Linux BPI-A 3.10.107-BPI-M2U-Kernel #1 SMP Thu Aug 24 08:01:24 CST 2017 armv7l GNU/Linux [email protected]:/home/pi/RPi.GPIO_BP#
The “gpio readall” read-outs all work for the pins i’ve tested: Pins 29 and 31 connected to display LEDs, and pins 33, 35, and 37 are connected with a button switch so that it is connected through a pull-up resistor to 3.3V when the button is not pressed, and ground when the button is pressed.
When I used RPi.GPIO 0.6.3 that was already installed on the BPi, reading from pins 33 and 35 works, with same output shown by “gpio readall”, but neither wait_for_edge nor add_event_detect are triggered by button presses. GPIO.output also works, the LED connected to the pin set to GPIO.HIGH lit up as expected.
When I used RPi.GPIO 0.5.8 from reading from pins 33 and 35 always show 1 even with button pressed, and still neither wait_for_edge nor add_event_detect are triggered by button presses. GPIO.output also does not work, the LED connected to the pin set to GPIO.HIGH did not lit up.
The functions wait_for_edge and add_event_detect both worked with another board, Raspberry Pi 3 Model B. Does the edge detection functions work with BPi M2 Berry?
Here is the test script for inputs I used: (Outputs I just used the python console)
#!/usr/bin/env python2.7 import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(33, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(35, GPIO.IN, pull_up_down=GPIO.PUD_UP) def falling_callback(channel): print "power edge detected." time.sleep(0.5) if GPIO.input(channel) == GPIO.LOW: print "Button was held down." else: print "Button was let go." return GPIO.add_event_detect(33, GPIO.FALLING, callback=falling_callback, bouncetime=100) try: while True: print "GPIO 33: ", GPIO.input(33) print "GPIO 35: ", GPIO.input(35) GPIO.wait_for_edge(35, GPIO.FALLING) print "red edge detected." time.sleep(1) print "Done sleeping." except KeyboardInterrupt: GPIO.cleanup()