I was wondering if there was a way that i could turn the power on and off on the 5V gpio pins with a python script. I am powering a fan with the 5V gpio and was hoping to do something where the fan only turns on when the temp gets too high on the pi.
Asked
Active
Viewed 2.0k times
7
-
1There are no 5V GPIO. All the GPIO are 3V3. – joan Apr 16 '16 at 14:51
-
on this site they state that there is 2 5V dc power pins https://www.element14.com/community/docs/DOC-73950/l/raspberry-pi-3-model-b-gpio-40-pin-block-pinout – WavePhaser Apr 16 '16 at 15:45
-
1Yes, there are two 5V power pins, pins 2 and 4. – joan Apr 16 '16 at 15:48
-
are you able to turn the power on and off on pins 2 and 4? – WavePhaser Apr 16 '16 at 15:49
-
2No. They are power pins. They are NOT GPIO. They are connected to the 5V supply rail. – joan Apr 16 '16 at 15:52
-
would there be any other easy way to turn a fan on and off if its powered with the 5V pin? – WavePhaser Apr 16 '16 at 15:56
-
1Plenty of ways. Whether they are easy or not depends on the components you have to hand. Put control fan speed in the search box. – joan Apr 16 '16 at 15:58
2 Answers
4
Keep the fan connected to the 5v pin. Connect the other side of the fan via a transistor to ground. Switch the transistor on and off via a GPIO pin. This will turn the fan on when the transistor is switched on and switch it off when the transistor is switched. There are plenty of web sites with how to do this.

Garnett Haines
- 315
- 1
- 2
- 4
-
That will work best for a fan with a voltage of say 5-7V and a currrent requirement of no more than a couple of hundred milliamp Maximum - a nice big capacitor between 5V and ground in the same circuit to avoid a big drop in supply voltage when the fan is turned on might not be a bad idea as well! @Milliways - not in the temperate region that the UK is admittedly in (some parts had snow today!) In some other geographical locations it might be an issue - depending on if the RPi is put in a case for instance I suppose. – SlySven Apr 17 '16 at 00:12
1
There is no need to write a program with recent Raspbian.
Only a single line needs to be added to cmdline.txt
dtoverlay=gpio-fan,temp=60000
See Fan Control

Milliways
- 59,890
- 31
- 101
- 209