24 to 12 hour

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
LitingWolf
 
Posts: 41
Joined: Thu Jan 02, 2020 3:03 pm

24 to 12 hour

Post by LitingWolf »

I have ds3231 rtc how do I change to 12 hour I know I have to change the bit but I don't know how to do that

User avatar
LitingWolf
 
Posts: 41
Joined: Thu Jan 02, 2020 3:03 pm

Re: 24 to 12 hour

Post by LitingWolf »

im using the adafruit rtc3231 lib

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: 24 to 12 hour

Post by adafruit_support_mike »

The CircuitPython module for the DS3231 doesn't have a function that changes the 12/24 setting, so you'll have to add one.

The instructions from the Register module explain how to do that in general terms:

https://github.com/adafruit/Adafruit_Ci ... n_Register

User avatar
LitingWolf
 
Posts: 41
Joined: Thu Jan 02, 2020 3:03 pm

Re: 24 to 12 hour

Post by LitingWolf »

Its Adafruit DS3231 Precision RTC Breakout the one i have

User avatar
adafruit_support_bill
 
Posts: 88141
Joined: Sat Feb 07, 2009 10:11 am

Re: 24 to 12 hour

Post by adafruit_support_bill »

Without knowing what language you are programming in, it is hard to provide specific advice. If programming in Python, you need to use the Registers module as Mike suggests. If programming in Arduino, you can use Wire._I2C_WRITE(). The 12/24 hour mode selection bit is bit 6 of register 0.02 as detailed on page 11 of the data sheet.
https://cdn-shop.adafruit.com/product-f ... DS3231.pdf

Note that changing the mode of the chip may confuse other functions in the library that may be expecting things in 24 hour mode.

A simpler approach is to just leave the chip the default mode and handle it in your code:

something like:

Code: Select all

if (hour > 12
{
    hour = hour - 12;
    PM = true;
}

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”