Page 1 of 1

RPi.GPIO Unexpected Warning "Channel already in use

Posted: Thu Apr 25, 2019 8:00 pm
by HopHead
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

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

Posted: Thu Apr 25, 2019 8:19 pm
by gordon77
GPIO.output( resetPin, GPIO.OUT) is incorrect,

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

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

Posted: Thu Apr 25, 2019 8:30 pm
by B.Goode
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.

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

Posted: Thu Apr 25, 2019 9:17 pm
by HopHead
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

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

Posted: Thu Apr 25, 2019 9:48 pm
by HopHead
Solved..

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