Hi, this code doesn’t work -
import board
import digitalio
import time
bottomCoverPin = digitalio.DigitalInOut(board.D27)
bottomCoverPin.direction = digitalio.Direction.OUTPUT
bottomCoverPin.value = False # Set the initial state to low (OFF)
def unlockBottomCover(bottomCoverPin):
try:
bottomCoverPin.value = True # Unlock top cover for 10s
time.sleep(10)
bottomCoverPin.value = False # Lock it back after 10 seconds
return {'message': 'unlockBottomCover', 'status': 'success'}
except:
return {'message': 'unlockBottomCover', 'status': 'error'}
it returns:
(ml) (base) scotty@ESR019:~$ /home/scotty/miniforge3/envs/ml/bin/python /home/scotty/Jetson_ESR/MQTT/test.py
WARNING: Carrier board is not from a Jetson Developer Kit.
WARNNIG: Jetson.GPIO library has not been verified with this carrier board,
WARNING: and in fact is unlikely to work correctly.
Traceback (most recent call last):
File "/home/scotty/Jetson_ESR/MQTT/test.py", line 5, in <module>
bottomCoverPin = digitalio.DigitalInOut(board.D27)
File "/home/scotty/miniforge3/envs/ml/lib/python3.8/site-packages/digitalio.py", line 183, in __init__
self.direction = Direction.INPUT
File "/home/scotty/miniforge3/envs/ml/lib/python3.8/site-packages/digitalio.py", line 213, in direction
self._pin.init(mode=Pin.IN)
File "/home/scotty/miniforge3/envs/ml/lib/python3.8/site-packages/adafruit_blinka/microcontroller/tegra/t234/pin.py", line 43, in init
GPIO.setup(self.id, GPIO.IN)
File "/home/scotty/miniforge3/envs/ml/lib/python3.8/site-packages/Jetson/GPIO/gpio.py", line 333, in setup
ch_infos = _channels_to_infos(channels, need_gpio=True)
File "/home/scotty/miniforge3/envs/ml/lib/python3.8/site-packages/Jetson/GPIO/gpio.py", line 124, in _channels_to_infos
return [_channel_to_info_lookup(c, need_gpio, need_pwm)
File "/home/scotty/miniforge3/envs/ml/lib/python3.8/site-packages/Jetson/GPIO/gpio.py", line 124, in <listcomp>
return [_channel_to_info_lookup(c, need_gpio, need_pwm)
File "/home/scotty/miniforge3/envs/ml/lib/python3.8/site-packages/Jetson/GPIO/gpio.py", line 110, in _channel_to_info_lookup
raise ValueError("Channel %s is invalid" % str(channel))
ValueError: Channel SPI1_SCK is invalid
Exiting...
Cleaning up pins
(ml) (base) scotty@ESR019:~$
but this code works just fine on the same device -
import RPi.GPIO as GPIO
import time
# Pin Definitions
output_pin = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.HIGH)
print("Cover is unlocked for 10s...")
time.sleep(10)
GPIO.output(output_pin, GPIO.LOW)
GPIO.cleanup()
Why is that? I don’t have any SPI devices connected