Using RTC DS3231
-
Hi, guys. i need your help. i'm using a RTC DS3231 and i have this problem:

I'm having this problem because of the least significant bit overflow?
what kind of function could I apply to fix this problem?
(00h address of seconds)
I would like to ream from 0-59s in integer. Thank you for your supp!
-
So, your trouble is second RTC register is in BCD format.
Something like this in line 18sec=(seg&0xF0)*10+seg&0x0F print(sec)will give you the correct int value
-
@Lucas_Vieira @Eric73 Actually it should (could) be:
sec = (segundos[0] >> 4) * 10 + (segundos[0] & 0x0f)
or
sec = (segundos[0] // 16) * 10 + (segundos[0] & 0x0f)
The conversion to seg is not needed, since array access to a single bytearray element returns an integer. -
'\t' is the same code as '\x09', see https://theasciicode.com.ar/ascii-control-characters/horizontal-tab-ascii-code-9.html
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login