Page 2 of 2

Re: [Video] ESP32 - DS1307 real time clock

Posted: Fri Apr 14, 2017 6:26 pm
by gregstewart90
Got it working! Thanks Kolban for your help. My problem was with localtime(). Before using it, you have to call time().

Code: Select all

time_t now_after;
time ( &now_after );
char buff_after[100];
strftime (buff_after, 100, "%Y-%m-%dT%H:%M:%S.000", localtime (&now_after));
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.

Thoughts?

Re: [Video] ESP32 - DS1307 real time clock

Posted: Mon Aug 14, 2017 12:32 am
by tbnobody
I am having exactly the same problem. I am using a DS3231 (which is nearly compatible with the DS1307) but I cannot read anything using the ESP-IDF. If I use the Arduino environment (as a component in an IDF project) everything works fine.
The arduino code which I am using is from this site: http://tronixstuff.com/2014/12/01/tutor ... h-arduino/

The IDF code which I am using is from here: https://github.com/nkolban/esp32-snippe ... c/ds1307.c
I am able to write the time but reading just gives me a timeout error:

Code: Select all

D (1108) ds3231: >> ds1307
D (1111) ds3231: >> writeValue: 1502670328
D (1115) ds3231:  - Mon Aug 14 00:25:28 2017

E (2120) ds3231: i2c_master_cmd_begin: 263
D (2120) ds3231: time: 14
ESP_ERROR_CHECK failed: esp_err_t 0x107 at 0x400e3aec

Re: [Video] ESP32 - DS1307 real time clock

Posted: Thu Aug 17, 2017 3:28 am
by kolban
I've always needed a logic analyzer (about $5-$10 on ebay) to debug I2C or SPI issues. Looking at the logic train on the wire is (for me) the only way to debug these kinds of issues.

Re: [Video] ESP32 - DS1307 real time clock

Posted: Sat Oct 12, 2019 4:04 pm
by musabaybek
The code that is provided here https://github.com/nkolban/esp32-snippe ... c/ds1307.c does not have make file, however I tried to create one and also component.mk files. But I face some errors like; "fatal error: errorhandle_func.h: No such file or directory"
I'm new to esp32 and idf based coding... Can you please help?