Get time from Pico

Hi,

I started writing some code in Python that would draw three arcs to represent the current time (hours, minutes and seconds) and present them on the Pico explorer board’s display. I got it working but it ran too slow so I’ve ported the code to C++ which runs about 100x faster.

The only thing I can’t figure out how to do is to get the actual clock time. I understand that this will be the time from power-on and that is ok. In Python I do:

utime.gmtime(utime.time())

but I’m having trouble figuring the equivalent in C++. I have figured out some C++ code but it just always returns 23:59.59. I’m hoping someone has had to do this and could put me out of my misery please.

Many thanks,

Steve

Have a look at this, might help.
Sync Pico RTC with host computer - Raspberry Pi Forums

Hi,

Many thanks for the info. The forum post you linked to led to me finding the answer and also I’ll be coming back to it to set the time directly from the host computer at some later stage of the development.

It seems that pico-examples already had an RTC example. Getting it to work from inside the pimoroni-examples (so I could access the Explorer display) proved difficult mainly because of my lack of knowledge of C++, libraries, linking etc.

In the end I created a brand new project and managed (by lots of googling and a fair bit of trial and error) to get both the RTC and the explorer display to work. It is a lot harder getting this to work in C++ than Python and, at the moment, I have to do a lot of unplugging of the USB cable which I didn’t have to do so much of with Python. I’m unplugging from the host end so as to protect my Pico USB port. I’ll look into getting debugging working at some point.

Here is a screenshot of the result. Lots of things to fix still but at some point I will put it on git hub:

Cheers,

Steve

I’m impressed, that looks awesome. =)

The clock can now be found at: GitHub - borgsoftwaresystems/clock-timer

Sorry it took so long.

Release uf2s can be found at:

There is a release uf2 for the Display pack and a separate release uf2 for the Explorer Base.

The code is in C++. I’m still learning the language and how to build so my code can do with some work.

Cheers,

Steve

I got one of these a few weeks back. Lots of room for this and that. =)
Large Solderless Breadboard : ID 443 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits
I “should” have a Pico Explorer arrive any day now, and already have a Pico Display Pack. I should be looking at what you posted early this week, thanks a bunch.=)