HopHead
Posts: 4
Joined: Thu Apr 18, 2019 9:12 pm

RPi.GPIO Unexpected Warning "Channel already in use

Thu Apr 25, 2019 8:00 pm

Hi all,

I get the following message:

Warning (from warnings module):
File "/home/pi/Documents/RPi_GPIO.py", line 20
GPIO.setup( TDCresetPin, GPIO.OUT)
RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.

The python code look likes:
import RPi.GPIO

resetPin = 4
GPIO.setmode(GPIO.BCM) #line 20
GPIO.setup( resetPin, GPIO.OUT)
GPIO.output( resetPin, GPIO.LOW)



The interface that are enabled are:
  • SSH
    VNC
    SPI
    Serial Port
    Serial Console
Code version:
Version:April 2019
Release date:2019-04-08
Kernel version:4.14

Additional Info:
I get the same error for GPIO22 (BCM 22) (header pin 15)
I can configure GPIO23 & GPIO24 (header pin 16, 18)
section of the 'config.txt'

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
Last edited by HopHead on Thu Apr 25, 2019 9:35 pm, edited 2 times in total.

gordon77
Posts: 5075
Joined: Sun Aug 05, 2012 3:12 pm

Re: RPi.GPIO Unexpected Warning "Channel already in use

Thu Apr 25, 2019 8:19 pm

GPIO.output( resetPin, GPIO.OUT) is incorrect,

Try GPIO.output( resetPin, GPIO.HIGH), OR GPIO.output( resetPin, GPIO.LOW)

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: RPi.GPIO Unexpected Warning "Channel already in use

Thu Apr 25, 2019 8:30 pm

As the text of the message says. It is a warning - provided for your information - not an error.

There are at least two options if it bothers you. One is to use the GPIO.cleanup() function at the end of your script to release or reset the use of the gpio pins. That way you won't see the report when you rerun the script.

The other - as stated in the message - is to use the GPIO.setwarnings() function to suppress the warnings.

There are other oddities in the code, like having an error on line 20 of a 5-line script, but perhaps they will become clearer as you make progress.

HopHead
Posts: 4
Joined: Thu Apr 18, 2019 9:12 pm

Re: RPi.GPIO Unexpected Warning "Channel already in use

Thu Apr 25, 2019 9:17 pm

Correction

the line is - GPIO.output(resetPin, GPIO.LOW) not GPIO.output(resetPin, GPIO.OUT)

Also a GPIO.cleanup() is called at the end of the script..

The whole script was not provided only the section that did GPIO

the line is GPIO.setmode(GPIO.BCM) #line 20 not GPIO.setup(GPIO.BCM) #line 20

HopHead
Posts: 4
Joined: Thu Apr 18, 2019 9:12 pm

Re: RPi.GPIO Unexpected Warning "Channel already in use

Thu Apr 25, 2019 9:48 pm

Solved..

Needed to make a successful run and cleanup.. aborting in the middle of a script did not execute a cleanup.. thus ..

Return to “General discussion”