2

I am trying to power a small 5V .21 A fan via GPIO pins 1 & 3. I am using pins 1 & 3 due to the nature of the fans connecter. I keep receiving the error:

fan.py:7: RuntimeWarning: A physical pull up resistor is fitted on this channel! GPIO.setup(3, GPIO.OUT)

My current code:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

GPIO(1, GPIO.OUT)
GPIO.setup(3, GPIO.OUT)

GPIO.output(1, 1)
GPIO.output(3, 1)

time.sleep(5)

GPIO.cleanup()
  • 2
    Pin 1 is connected to the 3V3 rail. Pin 3 is connected to a gpio (SDA). Don't try to power a fan using the gpios. It won't work and you'll probably kill the gpio and possibly the Pi. Also your code is set to use gpio numbers, not pin numbers. Gpio 1 is connected to pin 28 on recent Pis. Gpio 3 is connected to pin 5 on recent Pis. – joan Feb 10 '15 at 09:04
  • You are using the BCM scheme for the numbering - are you sure that is what you want to do? Also, the pi ports are generally 3v3 - can they really power the fan? If you want to power something, you generally want to connect it to power in one end and to GND in the other - but be careful not to fry your pi. If you would add a picture, that would probably be helpful. – Bex Feb 10 '15 at 09:10
  • @Bex A gpio shouldn't really be asked to provide more than about 20 mA. That will not power much of a motor. I believe the real problem for gpios is back EMF when the motor power is switched off. A fly back diode is a suggested solution. – joan Feb 10 '15 at 09:44

1 Answers1

2

Since you're using BCM numbering, the pin you're using is the SCL pin (used for spi communications) and has a pull up resistor. This is a general warning. and is something I've encountered before, and I found out why here: http://www.raspberrypi.org/forums/viewtopic.php?f=32&t=96128. I've been able to ignore this warning in my projects. As for running a fan, you do NOT want to power the fan from the RPi +5v line, you'll risk damaging the pi, etc, as noted above. You should use a separate power supply for the fan, and use the gpio to switch it on / off. In the case of a 5v fan, a transistor would be able to act as a switch, but anything requiring a higher voltage, you would want to use a relay. I drew a simple schematic for you to control your fan, please forgive my ms paint skillz.....

enter image description here

I hope this helps :)

Peter
  • 74
  • 3
  • 1
    That circuit has two drawbacks that I'd like to mention (either to take note or to fix it): 1) Ground, is mentioned to be a separate power supply, both grounds (Pi and second supply) need to be connected. 2) the transistor on the high-side (near + voltage) is not a useful circuit with an NPN transistor. Connect the emitter (the arrow) to ground and put the load (fan) between collector and +5V. See http://raspberrypi.stackexchange.com/questions/27928/power-a-5v-relay-from-gpio-pins – Ghanima Jan 20 '16 at 21:22