lane
Posts: 3
Joined: Thu Jun 04, 2020 3:58 pm

Driving a pin low when the Pi is halted

Thu Jun 04, 2020 4:10 pm

I have bought a fan for my Pi (Pimoroni Fan SHIM) and it defaults to turning the fan on when the control pin isn't driven. Due to this, it spins when the Pi is halted, but still plugged in. Is there a way to drive a pin (specifically BCM pin 18) low as soon as it's halted?

User avatar
thagrol
Posts: 2917
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Driving a pin low when the Pi is halted

Thu Jun 04, 2020 10:51 pm

The gpio-poweroff overlay? See /boot/overlays/README
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

lane
Posts: 3
Joined: Thu Jun 04, 2020 3:58 pm

Re: Driving a pin low when the Pi is halted

Fri Jun 05, 2020 12:03 pm

I've already tried gpio-poweroff, but it seems to be for turning off a power supply when the pi is turned off, and causes a kernels panic after a timeout runs out. This isn't what I need, as I just need the fan control pin to be low and the pi should then halt as usual

User avatar
thagrol
Posts: 2917
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Driving a pin low when the Pi is halted

Fri Jun 05, 2020 12:44 pm

By the time the kernel panics the OS has been effectively shutdown so no damage and/or corruption will occur. The bigger downside of gpio-poweroff is that you can no longer wake the Pi via GPIO 3 you have to use the run pin instead (or, maybe, global-en on a 4B).

Have you tried any of the software Pimoroni provide via their github? https://github.com/pimoroni/fanshim-pyt ... service.sh

Or asking them for assistance?

A posible hardware hack. No idea if it's practicle with the fan shim:
  • Disable console output to the serial port but leeave the serial port enabled.
  • Modify the ground lead of the fan cable inserting a transistor between the fan and the board.
  • Drive the transistor from the TX pin
The TX line is active low. It goes high on boot and low on shutdown
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

User avatar
penguintutor
Posts: 386
Joined: Tue May 08, 2012 9:11 am
Location: UK
Contact: Website

Re: Driving a pin low when the Pi is halted

Fri Jun 05, 2020 3:57 pm

When the Raspberry Pi is powered down then the GPIO is neither on nor off so goes floating.

If your control circuit for the fan has a high imedence (eg. a FET) then it may be seeing this as a signal and turning on accordingly.

You could try putting a large resistor between the GPIO pin and ground. This should have minimal effect when the port is active, but when it's floating it should pull the input down to zero. I'd suggest trying a 1K resistor from the GPIO pin to ground and see if that helps.

alphanumeric
Posts: 2513
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Driving a pin low when the Pi is halted

Sat Jun 06, 2020 9:35 am

The Fan Control Pin on the Fan Shim has to be pulled low to turn the Fan Off. That's what the service does, Low Off, High (or floating) On.
A fail safe of sorts I guess. You can install the Fan Shim with no software and it will run by default and cool your Pi. Install the software and you get on off control.
I added a pull down resistor to mine and it turned the fan off on shutdown. I started hearing a very faint kind of tick tick sound though. I think the fan was twitching / trying to start or something. I used a 10 K resistor though, maybe I should have used 1k instead?

alphanumeric
Posts: 2513
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Driving a pin low when the Pi is halted

Sat Jun 06, 2020 9:40 am

This mode is what I'm doing now, cutting a track on the board.
https://forums.pimoroni.com/t/fan-shim- ... 12169/8
I've been running it like this daily for months with no apparent issues.
I press the button, Pi turns off, fan turns off if its running.
Press it again, Pi boots up and fan only runs when my turn on temp is reached.

Return to “Advanced users”