Re: [Video] ESP32 - DS1307 real time clock
Posted: Fri Apr 14, 2017 6:26 pm
Got it working! Thanks Kolban for your help. My problem was with localtime(). Before using it, you have to call time().
I do have one problem. Sometimes the reads are okay and other times I get an error on i2c_master_cmd_begin(). The error is ESP_ERR_TIMEOUT. It will work for a long time and then on a reboot wont work. Eventually it starts working again after several reboots. Kolban I am using your code for the DS1307. I found this https://github.com/espressif/esp-idf/issues/422, but the solution didn't help.
Code: Select all
time_t now_after; time ( &now_after ); char buff_after; strftime (buff_after, 100, "%Y-%m-%dT%H:%M:%S.000", localtime (&now_after));