Ok, I have been poring over the linux man pages for (s)printf, and have come up with:
char SD_datetime[100];
sprintf(SD_datetime, "%s-%s-%s-%.2d-%.2d-%.2d", r[6], r[5], r[4], r[2], r[1], r[0]);
Serial.print("||||| sprintf version: ");
Serial.print(SD_datetime);
Serial.print("|||||");
where the r array is filled by
readDS1307(0, r, 8)
and readDS1307() is
uint8_t readDS1307(uint8_t address, uint8_t *buf, uint8_t count) {
// issue a start condition, send device address and write direction bit
if (!rtc.start(DS1307ADDR | I2C_WRITE)) return false;
// send the DS1307 address
if (!rtc.write(address)) return false;
// issue a repeated start condition, send device address and read direction bit
if (!rtc.restart(DS1307ADDR | I2C_READ))return false;
// read data from the DS1307
for (uint8_t i = 0; i < count; i++) {
// send Ack until last byte then send Ack
buf[i] = rtc.read(i == (count-1));
}
// issue a stop condition
rtc.stop();
return true;
}
The output I get is... blank.
Krupsi, I will next work on adapting your example into the code to see what happens. Thank you for providing a detailed answer!