Toggle Switch ON/OFF doesn't work

March 17, 2024, 18:20

killian3942

Hello, I've buy a Toggle Switch to start and shutdown properly my RPI 4, I've setup /boot/firmware/config.txt dtoverlay=gpio-shutdown and wired my toggle in GPI 5 and 6 (GRD). I success to shut and start one time, but despite, nothing happend. Do you have any idéea ? Thx !

killian3942

These one, but I try with arcade button and nothing happend too

oops.se

This is lacking info and it doesn't look like the way that Raspberry Pi Foundaition recommend.

killian3942

What’s kind of information do you need ?

oops.se

What lead you to toggle switches? What have lead you to two buttons? You should use push buttons. And have you read the official documentation?

killian3942

I read the official documentation yes, If I understand correctly the best way and the native way is to use dtoverlay. I prefer use manually this on off toggle switch but if push button is better I can use too. But I ve also try with push button and can’t shut/start with dtoverlay or other .py script I also try my toggle switch with .py script who only print gpio min status. And the result is good, I can print on or off status but can’t shut/start…

k9t33n

i know how to do it with two buttons but using one would require a micro controller

illegitimate_egg

how would you do it with 2?

illegitimate_egg

Also how would you start it back up?

k9t33n

i think. because you can turn it off - as in sudo poweroff - with gpio and then kill the power. but then turning it on would be where you have to turn the power back on like normal because i dont think you can turn it back on via gpio.

k9t33n

thats where the second button comes in

k9t33n

so if im correct to do it with one youd need a microcontroller to first shutdown the pi as to not break anything and then give it time to do so before cuting the power. and then just giving it power on startup

illegitimate_egg

I see, you could do this with basic transistor logic and a capacitor, or even better if you can find a reliable way to determine if the pi is off cut it when its off

k9t33n

does the pi still power the gpio power pins when its off?

illegitimate_egg

annoyingly I think it does

k9t33n

also how would that transistor logic and a capacitor set up look?

illegitimate_egg

idk, I didn't think about it

k9t33n

i mean you could just set a gpio pin to always be power until the pi is shutdown by a simple python script which launches on boot

illegitimate_egg

yes

illegitimate_egg

or

k9t33n

oh nice that works

k9t33n

where would the power go to the pi? gpio powered?

illegitimate_egg

yeah

illegitimate_egg

it powers the pi through GPIO

illegitimate_egg

don't worry, you can see its power condition circuit on top

k9t33n

yeah just saw the other pics

illegitimate_egg

although, upon looking lower, with the pi 4 its not suitable for high power applications

k9t33n

yes, could you find an alternative? ive not seen these before

oops.se

Ok, the documentation of Raspberry Pi is only stating that you can do "Shutdown" with dtoverlay=gpio-shutdown and to specify a specific pin you need to add dtoverlay=gpio-shutdown,gpio_pin=5 and it also say that it is a pulse aka "momentarily short". 1. By "pulse" means a short signal to GND = You can't use toggle switches. 2. Your missing the gpio_pin=5 in dtoverlay=gpio-shutdown in /boot/firmware/config.txt 3. And you can start the Raspberry Pi 4 by momentarily short (pulse) GLOBAL_EN on J2 to ground to restart a halted Raspberry Pi 4. See picture of J2 (3 round holes where one is labelled GLOBAL_EN). The middle hole is GND on J2. I Hope this clarifies everything.

oops.se

A warning, the GLOBAL_EN on J2 is 5volt logic.