Using clock function in AP mode

Hey gang, I know PB can keep time, but can it keep time when in AP mode and has no internet connection? Will it pull it from a device that connects to it? And keep counting as long as power is connected?

I want to set up a day night kind of timer on a PB AP. It doesn’t have to be very accurate, within a half hour would be fine. Based on my limited knowledge all I can think of is to program my own timer to count minutes from start up and then tell it what time it started counting. Am I missing something. If I’d thought of this earlier and used a V3 standard instead of a Pico, I could have just hooked up a photocell which would do what I need.

Thoughts?

You might still get away with that if you have a threshold circuit hooked up to the photocell that outputs a 3.3v or 0v signal to the GP0 pin on the Pico, which can then be read in code.

Maybe something simple, like a modification of this:

Replacing the motor with a resistor, the value read at the drain will be high while the MOSFET is off, and go low once it turns on.

There isn’t currently a way to set the clock used in the clock time functions outside of an internet connection.


You could definitely roll your own time functions by accumulating the delta milliseconds from each render cycle. You’d need multiple variables to avoid overflowing a variable (max 32,767). So e.g. have one accumulate milliseconds, then another to accumulate seconds, etc. When milliseconds >= 1000, subtract 1000 from it and add a second, etc. A series of showNumber and numberInput controls could allow you to set the time from the UI.

Nearly forgotten, the caveat with go0 is that it had to be high during boot. Might want a button or switch to prevent it from become a light dependent boot!

Thanks for the suggestions. Hope you and the family get to the festival!

1 Like