Hi,
I have RTC built on DS1307.
This is how I read the data:
void getClock()
{
Wire.beginTransmission(DS1307);
Wire.send(R_SECS);
Wire.endTransmission();
Wire.requestFrom(DS1307, 8);
second = Wire.receive();
minute = Wire.receive();
hour = Wire.receive();
wkDay = Wire.receive();
day = Wire.receive();
month = Wire.receive();
year = Wire.receive();
ctrl = Wire.receive();
}
I would like to get month, second, hour etc. as a decimal value.
How can I convert the data I get to decimal?
I’ve found the solution:
byte DS1305::decToBcd(const int dec) {
return ((dec / 10 * 16) + (dec % 10));
}
int DS1305::bcdToDec(const byte bcd) {
return ((bcd / 16 * 10) + (bcd % 16));
}