Failed to add edge detection - Raspberry Pi 4 GPIO

283 Views Asked by At

I am trying to run a LoRa receiver using Python.

from time import sleep
from SX127x.LoRa import *
from SX127x.board_config import BOARD
BOARD.setup()
class LoRaRcvCont(LoRa):
    def __init__(self, verbose=False):
        super(LoRaRcvCont, self).__init__(verbose)
        self.set_mode(MODE.SLEEP)
        self.set_dio_mapping([0] * 6)    
    def start(self):
        self.reset_ptr_rx()
        self.set_mode(MODE.RXCONT)
        while True:
            sleep(.5)
            rssi_value = self.get_rssi_value()
            status = self.get_modem_status()
            sys.stdout.flush()    
    def on_rx_done(self):
        print ("\nReceived: ")
        self.clear_irq_flags(RxDone=1)
        payload = self.read_payload(nocheck=True)        
        data = bytes(payload).decode("utf-8",'ignore')
        print (data)
        self.set_mode(MODE.SLEEP)
        self.reset_ptr_rx()
        self.set_mode(MODE.RXCONT) 
lora = LoRaRcvCont(verbose=False)
lora.set_mode(MODE.STDBY)

#  Medium Range  Defaults after init are 434.0MHz, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on 13 dBm
lora.set_pa_config(pa_select=1)
try:
    lora.start()
except KeyboardInterrupt:
    sys.stdout.flush()
    print ("")
    sys.stderr.write("KeyboardInterrupt\n")
finally:
    sys.stdout.flush()
    print ("")
    lora.set_mode(MODE.SLEEP)
    BOARD.teardown()

And it is giving this error: Failed to add edge detection.

I configured the access to SPI in Raspi-Config.

I installed these packages:

pip install spidev   
pip install pyLoRa
sudo apt-get install rpi.gpio
python-rpi.gpio
python3-rpi.gpio

I added in GPIO Group sudo groupadd -r gpio sudo usermod -a -G gpio pi

I ran it as SUDO but it continues giving the error: Failed to add edge detection.

0

There are 0 best solutions below