gpio.py:5: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings. GPIO.setup(8, GPIO.OUT) That is what I get after I run:

import RPi.GPIO as GPIO

GPIO.setup(7, GPIO.OUT)
GPIO.setup(8, GPIO.OUT)
GPIO.output(7, 0)
GPIO.output(8, 0)

Is there anyway I can fix the warning?

  • Also, what does GPIO.cleanup() do? Should I use it? – LilVinny Sep 18 '16 at 16:40

This code helped me get rid of the warning (the "finally" part at the end):

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme

GPIO.setup(6, GPIO.OUT) # output rf

# Initial state for LEDs:
print("Testing RF out, Press CTRL+C to exit")

     print("set GIOP high")
     GPIO.output(6, GPIO.HIGH)
except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
   print("Keyboard interrupt")

   print("some error") 

   print("clean up") 
   GPIO.cleanup() # cleanup all GPIO 
| improve this answer | |

You can safely ignore the warning.

As the message says add GPIO.setwarnings(False) to the start of your script to disable warnings.

GPIO.cleanup() sets any GPIO you have used within RPi.GPIO to INPUT mode. If that behaviour is desirable call the method before exiting your script.

| improve this answer | |
  • Is there a way that I can repeat the script after every 5 minutes and after every loop turn the lights off. – LilVinny Sep 18 '16 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.