2

Yesterday everything was working fine, but today I ran the same code and I am getting the following error even though nothing has physically changed:

test3.py:8: RuntimeWarning: A physical pull up resistor is fitted on this channel!
  GPIO.setup(2, GPIO.OUT)
test3.py:9: RuntimeWarning: A physical pull up resistor is fitted on this channel!
  GPIO.setup(3, GPIO.OUT)

The code I am running is to operate a relay:

import RPi.GPIO as GPIO
from time import sleep

# The script as below using BCM GPIO 00..nn numbers
GPIO.setmode(GPIO.BCM)

# Set relay pins as output
GPIO.setup(2, GPIO.OUT)
GPIO.setup(3, GPIO.OUT)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)

# Time to sleep between operations in the main loop
SleepTimeS = 0.5

# Main Loop
try:
        while (True):

            # Turn all relays ON
            GPIO.output(2, GPIO.HIGH)
            GPIO.output(3, GPIO.HIGH)
            GPIO.output(4, GPIO.HIGH)
            GPIO.output(17, GPIO.HIGH)
            # Sleep for 5 seconds
            sleep(SleepTimeS)
            # Turn all relays OFF
            GPIO.output(2, GPIO.LOW)
            GPIO.output(3, GPIO.LOW)
            GPIO.output(4, GPIO.LOW)
            GPIO.output(17, GPIO.LOW)
            # Sleep for 5 seconds
            sleep(SleepTimeS)

# End program cleanly with keyboard
except KeyboardInterrupt:
    print "Good bye!"
    GPIO.cleanup()

Any ideas on how to fix this? I tried adding pull_up_down=GPIO.PUD_DOWNbut I just get the same error.

Darth Vader
  • 4,218
  • 24
  • 47
  • 70
CJ0206
  • 33
  • 1
  • 1
  • 6

2 Answers2

3

You have a number of choices.

  • ignore the warning
  • switch RPi.GPIO warnings off (see its documentation)
  • don't use GPIO 2/3 (pins 3/5) which have the hard-wired pull-ups
joan
  • 71,852
  • 5
  • 76
  • 108
0

A fresh install of raspbian has fixed the issue, whatever I tinkered with yesterday must of activated the pull up resistors.

CJ0206
  • 33
  • 1
  • 1
  • 6