jinksto
Posts: 3
Joined: Fri Jul 12, 2019 9:15 pm

GPIO 36 invalid channel? RPi4

Fri Jul 12, 2019 9:22 pm

I'm migrating a service that works on a 3B+ to a new 4.

uname -a : Linux raspi4 4.19.57-v7l+ #1244 SMP Thu Jul 4 18:48:07 BST 2019 armv7l GNU/Linux

Code: Select all

#!/usr/bin/python
import RPi.GPIO as GPIO
from time import sleep
from shutil import copyfile

GPIO.setmode(GPIO.BOARD)
GPIO.setup(36,GPIO.IN)
GPIO.setup(12,GPIO.OUT)
...
I get this error when I try to run the code:

Code: Select all

Traceback (most recent call last):
  File "./doorsense.py", line 7, in <module>
    GPIO.setup(36,GPIO.IN)
ValueError: The channel sent is invalid on a Raspberry Pi

I feel like I've forgotten something simple but can't figure it out. This is a really simple door sense circuit that's only on or off. I copied the code directly from the 3B+ that's working great.

trejan
Posts: 2620
Joined: Tue Jul 02, 2019 2:28 pm

Re: GPIO 36 invalid channel? RPi4

Fri Jul 12, 2019 11:00 pm

RPi.GPIO needs an update for the RPi 4. Prerelease instructions here. It'll get pushed out as a regular update soon so you should be able to just wait for the update.

jinksto
Posts: 3
Joined: Fri Jul 12, 2019 9:15 pm

Re: GPIO 36 invalid channel? RPi4

Sat Jul 13, 2019 12:19 am

trejan wrote:
Fri Jul 12, 2019 11:00 pm
RPi.GPIO needs an update for the RPi 4. Prerelease instructions here. It'll get pushed out as a regular update soon so you should be able to just wait for the update.
That did the trick! Thank you. I thought I was losing it.

Jesash
Posts: 1
Joined: Tue Jul 16, 2019 7:34 pm

Re: GPIO 36 invalid channel? RPi4

Tue Jul 16, 2019 7:48 pm

I applied the update as described and the code below:

Code: Select all

import RPi.GPIO as gpio
gpio.setmode(gpio.BCM)
gpio.setup(17, gpio.IN)
gpio.setup(17, gpio.IN,pull_up_down=gpio.PUD_UP)
import time

while True:
    input_value = gpio.input(17)
    if input_value == False:
        print('The button has been pressed...')
        while input_value == False:
            input_value = gpio.input(17)
        time.sleep(0.3)
did work! Apparently pulling up and down on input pins now works. Will this also be updated in gpiozero?

Return to “Troubleshooting”