I want to use GPIO 3 (wake) and any ground pin (6,14,20,25,30,34,39) for a power on/off switch.
And no, there’s no other option than GPIO 3 for this functionality.
With Pimoroni’s fan shim mounted, can I use GPIO 3?
And what happens to the fan I connect GPIO 3 to ground while the Raspi is on and the fan is running?
The button on the Fan Shim grounds GPIO 3 and GPIO 17 when pressed.
If you shut down and leave the Pi powered, pressing the button will have the Pi Boot up again.
Adding the following entry to your config.txt file will have the Pi do a proper shutdown when the button is pressed.
You can also control the fan on off with another dtoverlay entry.
Turns it on at 55c and off again at 45c. Edit the 55000 for the on temp you want.
Fan Shim BCM 17 Pin 11 Button
Fan Shim BCM 18 Pin 12 Fan Control
Fan SHIM at Raspberry Pi GPIO Pinout
The fan is going to run when you shut down though.
Fan Shim Button to turn Pi on and off FYI post - Discussion - Pimoroni Buccaneers
Thanks for your reply.
I’m running the Raspi headless.
Therefore I will add the power on/off switch, because I cannot use the Fan Shim button.
So I guess connecting a switch to GPIO 3 and ground pin would be in parallel to the Fan Shim and not interfere with it.
That will be fine, its not going affect the Fan Shim.
Will have the Pi Shut down when GPIO 3 is grounded. Only works if i2c is disabled though. The one button / pin can then do shut down and boot up.
I have no intention to use i2c.
This Raspi will be used as a control plane of a K3s node.
Anyway, let me summarize my understanding:
- Fan Shim already provides a function for shutdown and boot using button
- an additional switch can be connected to pin 5 (= GPIO 3) and pin 6 (= ground)
- I must add
dtoverlay=gpio-shutdown to /boot/config.txt
However, I don’t understand this statement:
"Adding the following entry to your config.txt file will have the Pi do a proper shutdown when the button is pressed.
What do you mean with proper shutdown?
And what’s the difference to a shutdown using GPIO 3?
Is just a short version of the entry that uses GPIO 3 by default.
Is the long version that lets you specify a different GPIO pin. I used pin=17 because that’s the pin the Fan Shim button uses.
By “proper shutdown” I mean that using this overlay does the same thing as doing a shutdown from the OS menu or command line. Your not just killing the power.
Now I understand.
However GPIO 17 will not boot up the Raspi (after shutdown and still powered), right?
Means I must connect the switch to pin 5 and ground if I want shutdown and bootup controlled by the switch.
Yes, GPIO 17 will not boot the Pi up. Only GPIO 3 does that.
Now, after modifying /boot/config.txt and rebooting Raspi I’m verifying the Fan Shim button.
For a short press: fan starts/stops spinning.
For a long press, the LED flickers blue.
There’s no shutdown.
What is wrong here?
This is the buttom line of my /boot/config.txt:
# NB: "dtoverlay=gpio-shutdown" will enable Fan Shim button for RPi power on/off using GPIO 17.
What fan shim software have you installed?
fanshim-python from here following the installation instructions here.
The service installed works:
$ sudo systemctl status pimoroni-fanshim.service
● pimoroni-fanshim.service - Fan Shim Service
Loaded: loaded (/etc/systemd/system/pimoroni-fanshim.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-03-05 15:21:40 CET; 4min 1s ago
Main PID: 463 (python3)
Tasks: 2 (limit: 4532)
└─463 /usr/bin/python3 /opt/fanshim-python/examples/automatic.py --on-threshold 55 --off-threshold 45 --low-temp 45 --high-temp 55 --delay 2 --bri>
Mär 05 15:21:40 eddie systemd: Started Fan Shim Service.
Ah, OK, I don’t think that button, fan on off ever worked for me?
There is a,
–nobutton option to turn button off and
–noled option to turn the LED off.
that I’ve been using, forgot all about that, sorry. The --nobutton option should get things working the way you want.
In my crib notes I have the following.
sudo ./install-service.sh --on-threshold 65 --off-threshold 40 --delay 2 --nobutton --noled
–nobutton to turn button off and
–noled to turn the LED off.
sudo systemctl stop pimoroni-fanshim.service
sudo ./install-service.sh --on-threshold 75 --off-threshold 60 --delay 5
sudo systemctl stop pimoroni-fanshim.service
sudo systemctl disable pimoroni-fanshim.service
sudo systemctl enable pimoroni-fanshim.service
sudo systemctl start pimoroni-fanshim.service
If I disable Fan Shim button using
--nobutton, I need another script, right?
Would this be the working script?
The nobutton option just tells the fan shim service to ignore the button. It doesn’t affect anything else monitoring it. The dtoverlay “should” then work.
The modification done in that other thread changes the way the fan works. it will default to off, and have to be commanded on by the fan shim service. It doesn’t effect how it works via the service. When you shut the Pi down, it will turn off though, instead of staying on.
Right… now things are clear.
- Fan Shim software is now configured to work w/o button, means only automatic fan control
- Power off button is now defined in /boot/config.txt
If I press the button now when Raspi is on, nothing happens.
If I long press the button now when Raspi is on, nothing happens.
If I press the button now when Raspi is off (with red LED on), OS is booting.
This means, shutdown function with button is still not working.
Make sure i2c is disabled.
i2c is not enabled / loaded:
$ sudo lsmod
Module Size Used by
nfnetlink 16384 2
raspberrypi_hwmon 16384 0
gpio_keys 20480 0
rpivid_mem 16384 0
uio_pdrv_genirq 16384 0
nvmem_rmem 16384 0
uio 24576 1 uio_pdrv_genirq
aes_neon_bs 28672 0
aes_neon_blk 28672 1 aes_neon_bs
crypto_simd 24576 2 aes_neon_bs,aes_neon_blk
cryptd 28672 1 crypto_simd
fuse 131072 1
ip_tables 32768 0
x_tables 45056 1 ip_tables
ipv6 532480 22
I don’t know why its not working?
Is there any tool to test / verify the GPIO?
My understanding is that GPIO 3 and GPIO 17 should get 0 when pushing Fan Shim button.
Edit the dtoverlay entry to the short version.
and see if it changes?
That will switch it from GPIO 17 to GPIO 3. can’t hurt to try it.