7

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.

WavePhaser
  • 71
  • 1
  • 1
  • 3

2 Answers2

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
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
  • 62,573
  • 32
  • 113
  • 225