GPIO questions about edge

According to this pinout:

https://wiki.radxa.com/Rock5/hardware/5b/gpio

Yes!
I only update the GPIO’s address for pins 16 and 18 on a previous answer…

I’ve tested Callbacks for IRQ and it worked for me!

could you send me the python script you used to test callbacks so I can test on my radxa5?
following is the script I am testing, I have a rain gauge hooked to pin 23. I didn’t bother with radxa file for pins, just changed the pin mapping file.
#!/usr/bin/python3
import time
import sys

import OPi.GPIO as GPIO
GPIO.setwarnings(False)
channel = 23
GPIO.setmode(GPIO.BOARD)
GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

rainTick = 0 # Count of the rain input trigger
interval = 5 # Set now to define scope of variable
rainTime = 0 # Use this to detect erroneous rain events

def raintrig(channel):
time.sleep(0.02) #added 05-12-2020 to see if helps error in rain waits 10ms
global rainTick
global rainTime
rainTick += 1
print(“in raintrig”, rainTick)

GPIO.add_event_detect(channel, GPIO.FALLING, callback=raintrig)
GPIO.add_event_callback(channel, raintrig)

while True:
print(‘Reading…’)
if GPIO.input(channel) == GPIO.LOW:
print(‘Pressed’)
else:
print(‘Released’)
time.sleep(2)

You can try:

import time
import sys

import OPi.GPIO as GPIO

don’t turn off the warnings while you are testing.

GPIO.setwarnings(False)

channel = 23
GPIO.setmode(GPIO.BOARD)

Check if the "Pull down command is working, in my case, this doesn’t work. you manually need to put a resistor to reach this.)

GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

Clean the channel from previous configurations. (You must use this also at the end of your script.)

GPIO.cleanup()
time.sleep(1)
GPIO.remove_event(channel)

rainTick = 0 # Count of the rain input trigger
interval = 5 # Set now to define scope of variable
rainTime = 0 # Use this to detect erroneous rain events

def raintrig(channel):
time.sleep(0.02) #added 05-12-2020 to see if helps error in rain waits 10ms
global rainTick
global rainTime
rainTick += 1
print(“in raintrig”, rainTick)

GPIO.add_event_detect(channel, GPIO.FALLING, callback=raintrig)
GPIO.add_event_callback(channel, raintrig)

while True:
print(‘Reading…’)
if GPIO.input(channel) == GPIO.LOW:
print(‘Pressed’)
else:
print(‘Released’)
time.sleep(2)

I put a 330 ohm resistor in the circuit. I added GPIO.cleanup(). Changed the warnings to true. I am running the script thru Thonny so doubt it matters.

Ran the script again with the changes and no difference
RPi
I have been running this basic script using RPi.GPIO on a raspberry for over 3 years. It is running right now. That is why this is so frustrating.

Please send me the python script that you tested callback so I can test my here, Thanks

Please check this snippet , I test it on a a radxa CM3 board.

Modify the required parameters.
Also, I made a mistake in my previous reply. You cannot GPIO.cleanup() after GPIO.setup() the pin. Sorry for that.
Check this out:

import time
import radxa.radxa_cm3_io
from OPi import GPIO as GPIO

GPIO.cleanup()
time.sleep(5)
GPIO.setmode(radxa.radxa_cm3_io.SBC)

pin = 19
pin2 = 15

i=0
def interrupt(var):
global i
i=i+1
print(f"event number {i}")
print(f"Event triggered by pin: {var}")

#GPIO.setwarnings(False)
try:

GPIO.setup(pin, GPIO.IN)
GPIO.remove_event_detect(pin)
GPIO.setup(pin2, GPIO.IN)
GPIO.remove_event_detect(pin2)
# time.sleep(5)
# print( GPIO.input(pin) )

GPIO.add_event_detect(pin, GPIO.FALLING, callback=interrupt)
GPIO.add_event_detect(pin2, GPIO.FALLING, callback=interrupt)
# 
while True:
    print( f"Pin number { pin } is: { GPIO.input(pin) } " )
    print( f"Pin number { pin2 } is: { GPIO.input(pin2) } " )
    time.sleep(1)

except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()

radxa cm3 io uses a different cpu chip so I don’t know why the code would run on radxa5 just because it runs on cm3.

Also this can’t be python3 script as the indents all mostly wrong. Also I can’ run
import radxa.radxa_cm3_io on radxa5.

From Thonny:
Traceback (most recent call last):
File “/home/pi/OPiTest6.py”, line 22, in
GPIO.setup(pin, GPIO.IN)
File “/home/pi/.local/lib/python3.9/site-packages/OPi/GPIO.py”, line 477, in setup
sysfs.unexport(pin)
File “/home/pi/.local/lib/python3.9/site-packages/OPi/sysfs.py”, line 45, in unexport
fp.write(str(pin))
OSError: [Errno 22] Invalid argument

thanks for all your suggestions, hope someone with an radxa5 will pitch in with some answers.