After trying a few scripts and them not working I've now got a script that works and I can now safely shutdown my raspberry pi with the push of a button. It uses pin 26 which controls the servo and the independent up button so I can clear the use of an external switch
I have been trying to get this power switch to function properly, but regardless of if I use the boot folder or the rc.local for the power button start up, my I2c devices (lcd, matrix and light sensor) all end up with a timeout error.
Is there a way where I can use both a power switch and the I2c?
I'm aware the run global gnd is possibly used for a power button but I'm not sure it'd work and don't want to ruin my rpi4b what else can I possibly do without errors like that coming up?
That post is extremely helpful. It's very clear and informative.
For example I kind of understand why the I2C was clashing as I basically didn't have the dtoverlay which I assume reserves that pin for a default function (a power button for example).
So if I use a power button script and include the dtoverlay in the boot config then it'll make the button a default reserved function that would be separate from all other connections
Comments
You should use pin 26 and GND to connect your power switch.
You sure can use the button matrix or 4 individual buttons to act as a power button and what you need is to program to achieve it.
Daaaaang, thank you Tony!
I'll be working on that then as my project!
Thank you again you've been a massive help
After trying a few scripts and them not working I've now got a script that works and I can now safely shutdown my raspberry pi with the push of a button. It uses pin 26 which controls the servo and the independent up button so I can clear the use of an external switch
Thank you
I have been trying to get this power switch to function properly, but regardless of if I use the boot folder or the rc.local for the power button start up, my I2c devices (lcd, matrix and light sensor) all end up with a timeout error.
Is there a way where I can use both a power switch and the I2c?
I'm aware the run global gnd is possibly used for a power button but I'm not sure it'd work and don't want to ruin my rpi4b what else can I possibly do without errors like that coming up?
Also can I get an explination on why the I2C and power switch are clashing
Power switch and I2C should not clash, there might be some error in your script or operation.
Is there a script you could recommend?
@nicholasperratt
Please read this post that I wrote. It looks like what you are trying to accomplish.
@Pearl
That post is extremely helpful. It's very clear and informative.
For example I kind of understand why the I2C was clashing as I basically didn't have the dtoverlay which I assume reserves that pin for a default function (a power button for example).
So if I use a power button script and include the dtoverlay in the boot config then it'll make the button a default reserved function that would be separate from all other connections
I have the dtoverlay and connected to the pins 5 and 6(gpio3 and gnd) and all that happens is the momentary switch stops the I2C momentarily.
I have also tried dtoverlay=gpio-shutdown, gpio_pin=33 and still not shutting down