Hello,
So I'm not waiting for the "it gives hour to your Arduino" answer, what I really want to know it's if we can read numbers one by one.
Let's imagine the time is 05:42, can I read 0, then 5, then 4, then 2, like 4 infos?
H1 H2 : M1 M2
0 5 : 4 2
And if, how can I do it.
I'm planning to code a simple clock with addressable LEDs, one strip to do one 7 segments digit.
So it's gonna be easier for me to have only 10 numbers to create, instead of 23 for the hour and 59 for the minutes.
If you have any answer or leading to a similar topic, with pleasure 
Thanks a lot,
Clément
With most, if not all RTCs, you can read the "numbers" one by one. You can also have 12 hour or 24 hour timekeeping. See the data sheet for the details.
Looking at the datasheet of the DS3231 real time clock as an example, I see that the numbers are essentially in binary-coded-decimal (BCD) form. So 42 minutes would be read in one byte as:
01000010
where the first four bits represent "4" and the last four bits represent "2".
Anyway, whatever the format your real time clock gives, you will always be able to derive the individual decimal digits by code.
So with the DS3232 for example, if the 'minutes' byte is read into a byte variable named "bcd":
tens = bcd/16; //integer division
units = bcd%16; // modulo arithmetic operator
It's worth pointing out that reading the BCD values one at a time risks an error if there is a rollover. For example, if you read the the mintes as "1" and the seconds as "0" you won't know if the time is really 1:00 or 2:00 since it could have gone from 1:59 to 2:00 in between the reads.
There are different strategies for dealing with this possibility. One is to read the values a second time and compare them. The DS3231 provides another way. It uses the start of an I2C transfer to synchronize the time with static user registers. If you read all of these registers in one I2C transfer you are guaranteed consistent values. If you read them one at a time each request will trigger a reload of the user registers and you could get inconsistent values. The solution with the DS3231 is to read all of the time/date registers in one go. But RTC chips vary so you have to read the datasheet; or use the double read method.
To me this is more of a simple coding issue rather than needed to be able to read each BCD digit from the RTC.
I'd recommend using a RTC library.
From that library get the time which will be atomic so you don't have to worry about the atomicity issues of time changing between reading the BCD digits.
Then write the code to strip out the BCD digits within the hour and minutes as needed.
As Archibald showed, it is a very simple calculation to do the conversion.
--- bill
bperrybap:
I'd recommend using a RTC library.
From that library get the time which will be atomic so you don't have to worry about the atomicity issues of time changing between reading the BCD digits.
It depends on the library. It isn't hard to find ones that fail to ensure atomicity.
So with the DS3232 for example, if the 'minutes' byte is read into a byte variable named "bcd":
tens = bcd/16; //integer division
units = bcd%16;
// [modulo](https://www.arduino.cc/en/Reference/Modulo) arithmetic operator
Although most libraries use the RTC in non-BCD mode, in that case you can easily get display values in a similar way:
tens = bcd/10;
units = bcd%10;
I think using BCD is unhelpful because it complicates any time arithmetic you want to do.
aarg:
I think using BCD is unhelpful because it complicates any time arithmetic you want to do.
Agree. IMO, the only way to deal with time when needing calculations is using a datetime epoch which makes all the calculations trivial.
Then simply convert from the epoch back to "human" time of year,month,day,hour,min,sec etc...
That said, BCD is often needed for other purposes like indexing into a table for the 7 segment data needed to drive a 7 segment LED for each time digit which is what the OP mentioned.
There are several RTC libraries out there that use the Time library which tracks time using a unix epoch.
(Some use an epoch format without using the Time library)
As a result when you get the datetime, it will always be atomic and you can use the library macros/functions to extract any field you need.
If using the Time library you can also use the TimeAlarms library for any desired/needed alarms.
--- bill