Turn arduino on and off with momentary pushbutton

Basically to hold the state a little longer in case the MCU pin take a little longer to settle.

1 Like

a bit messy but works

1 Like

I get how the capacitor value would do that, and that makes sense.
I raise POWER_HOLD_PIN in the first line of setup() and it's never had an issue, but I could see that being a solid improvement. What value would you recommend?
Also how does raising R3 help in that matter?

My workshop is a bit messy but it works too. Looks good

1 Like

It would ... right.
It would allow the cap to discharge a little slower. Also help the cap charge up a little bit better.

What value?
Well, for the cap I would pick an electrolytic cap (of basically whatever value I have; I dont own a warehouse). Which typically means a 5uF to 20uF. a 1uF seems too small, and a 50uF/100uF seems a bit overkill, but perhaps I am wrong.
Resistor would be basically between 20k-50k.

How does the output turn off, however. Is the MOSFET a toggle?

1 Like

Fantastic, now both make sense. Thank you.
I'll kerjigger it a bit and test it some more.
Good revision recommendation.

1 Like

Same idea, the button is connected to the battery directly, and battery has protection circuit so 3.2V maybe is the lowest and then it won’t switch on

Not bad. I've been taught to try to avoid hot buttons.
PA7 is your power hold pin?

PB0 is, PA7 is input, allows to detect button press when system is on, but I think I moved it to esp32 in the end to handle all holds and inputs. it was a process

Nice, so you have the same features.
I like that the MCU can turn off the PSU on its own and still detect the button press, which could be retasked after startup.
I typically use long-press to turn off the system. It also gives time for a shutdown and save sequence.

Wouldn’t you just need to hold the button for 0.11 seconds longer for system to power up if you don’t change values? What’s the worst that could happen, the hold pin wouldn’t be initialised so it would power down when you release? but then we are talking about super momentary action from super fast person

same

0.11 is not bad, but I do see the point. When I poll buttons, I aim for a 0.05 capture. Little more than doubling R3 should help with that, I think.

Not the real value though, was just making a point

1 Like

Now I'm itching to calculate it or test it with my tiny scope.

2 Likes

555 delay off relay.....few cents each on internet shops.

Ok....
So this is the circuit I should use?


And is this power hungry? I want it as low-powered as possible whenever it isn't on the charger.

Where does it test for the battery being charged? My original circuit has two small leds - one shows charging, one shows charged. But these will be hidden inside a case, so I want my OLED screen to show the status instead. This is the LED setup:

@bluejets How power hungry is a relay?!?

I have to look closer to be sure about the circuit, but the itty bitty current might drain a battery in 70 years or so.

1 Like

Perfect!

Some of the users with more experience will have to review this for you. I wouldn't build it until others have weighed in on it.

1 Like