It is a work in progress, but I am working on a Micro:bit Watch. It will be reading the time from a I2C RTC timer IC and show it is a custom way on the display (non-scrolling text). Allowing for setting the time, either remotely using serial or bluetooth or when on startup holding the A+B button maybe.
But to get the time I needed an extension for the DS3231 and so far I only found something for micropython and mbed, so I started my own and had a quick test: https://github.com/gbraad/pxt-rtc-ds3231 and it works.
keep an eye out for a full release soon.
Note: pins on the backside aren’t connected. Still needed to add this to the documentation. Started this as a gift for the holiday but due to the situation here in China I was unable to source everything, especially motivation!
Shows time (HH:mm) when A is pressed, and with seconds (HH:mm:ss, ss, ss) when B is pressed.
Using a nanobit with an oled display and the ds3231 module
Great to find this! I am starting on a microbit add-on RTC using the DS3231 (I wrote up a how-to for a DS1307 board a while ago).
Before attempting to write an extension, I thought of writing get_time and set_time functions using only Makecode blocks. The get_time works fine, but I can’t get the set_time to work!
Maybe the i2c extension is limiting me, in that I don’t see how to write the 12c word address followed by a data byte. Any ideas?
Are you close to publishing your extension?
Cool! Thanks for sharing! I’m looking forward to seeing the final product (whoops…didn’t notice this was an older thread. The below was mainly a follow-up to gbraad’s work)
For what it’s worth, I wrote a reasonable reliable time extension that doesn’t need an RTC. I wrote it largely for summer camp activities where kids make micro:bit smart watches.
If anyone wants to give it a try, you can search in the extensions for “microbit-pxt-timeanddate”. Or visit the docs here: https://makecode.microbit.org/pkg/bsiever/microbit-pxt-timeanddate . It’s got blocks that support a variety of different time/date formats and features, like callbacks to support alarm functionality. The docs also describe and show examples of three different ways to set the time.
The one bug that’s been reported: If someone uses the
start melody ... repeating infinite in the
forever it stops updating time. (I haven’t had a chance to look into the cause, but I suspect the
forever loop is blocking a behind-the-scenes
forever loop that ensures the clock is periodically updated)
Of course there are the two huge advantages of the external RTC: battery backup and it’s dedicated to updating the time (so lacks the potential freeze problem I described).
Thanks Bill, I saw that extension.
By the way (separate topic) I adapted your WebUSB terminal to add a timestamp - but it has recently stopped working, and so has your webUSB terminal. Something must have changed. Any ideas?
I’m glad someone is getting some use out of that (or was anyway).
I just did a quick test:
- Used makecode to create a project that streams out x:N (where N an accelerometer value)
- Use the live version of microbit-webusb (directly from the GitHub site)
Data streamed in as expected. Much of the process I use is pulled directly from Makecode (I figured it wouldn’t change much because it’d break a lot of backward compatibility)
I was using a recent version of Chrome — what browser are you using?
Hi - I have just tried my webUSB terminal (based on yours) - and it works! Maybe it was finger trouble or a Chrome version. My current Chrome is 84.0.4147.136 (Official Build) (64-bit)
My (very early) repo for the DS3231 is here: https://github.com/keble6/pxt-DS3231
Extensions are all new to me, so I am still working my way through the documentation!
The DS3231 has a rather odd oscillator control bit - it allows you to stop the clock when the chip switches to battery mode. I’m not sure that’s useful to anyone! But I have included it. I haven’t done alarms yet. Maybe later. My tests look good.
My code lives here: https://github.com/gbraad/pxt-rtc-ds3231
I forgot to publish it here? ah nope, it WAS published in the first message and got 10 clicks
Never got around to finish the watch as I got drawn into R/C car projects with the v2x2 protocol and nRF24 compatibility. Anyway, just thought of the watch a day ago and will finish it soon.
I never bothered about the other functionality, like day, month and year or even the alarm, but did extract the BCD code into another extension. http://github.com/gbraad/pxt-bcd as several other extensions I made needed this.
Hi… I am utilizing the DS3231 model record from the RTCLib now.
I have really taken a stab at running this sketch six distinct ways while isolating the DS3231. The “default” where the time depends on when the sketch is aggregated, just as uncommenting the line where you can set the time (which is the thing that I use in my venture). Neither works. Additionally, I attempt to run each with and without the battery. At long last with power not from the Uno, nut a different inventory. Again no distinction in yield on the chronic screen.
It is odd as this ran on my seat for a while as a feature of my clock venture. Used to allow it to run a day or two just to ensure the entire task was all the while turned out great.
Not certain on the off chance that it is important, but rather the clock I made has three LED catches to change highlights: one each for Hour, Minutes and Color. The shading one actually turns out great, the moment and hour ones no longer addition the clock.