Pin busy

July 23, 2024, 16:47

catguy12321

I'm trying to connect a RFM95W LoRa module and a button to a raspberry pi, but it returns a GPIO Busy error at CE1. I tried rebooting but still doesn't work. error message:
bash
Traceback (most recent call last):
  File "/home/raspberry/radio.py", line 11, in <module>
    CS = DigitalInOut(board.CE1)
         ^^^^^^^^^^^^^^^^^^^^^^^
  (redacted traceback stuff)
  File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
    raise error(error_text(v))
lgpio.error: 'GPIO busy'
code:
python
import time
import busio
from digitalio import DigitalInOut, Direction, Pull
import board
import adafruit_rfm9x

btnA = DigitalInOut(board.D17)
btnA.direction = Direction.INPUT
btnA.pull = Pull.UP

CS = DigitalInOut(board.CE1)
RESET = DigitalInOut(board.D25)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

iter = 0

def send_data():
    global iter
    print("send %s"%iter)
    iter+=1

def get_data():
    global iter
    print("get %s"%iter)
    iter+=1

def main():
    try:
        while True:
            if not btnA.value:  # Button pressed
                send_data()
            else:
                get_data()
    except KeyboardInterrupt:
        pass

if __name__ == '__main__': 
    main()

catguy12321

Nvm, fixed by resetting raspberry pi