[Video] ESP32 - DS1307 real time clock

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

Re: [Video] ESP32 - DS1307 real time clock

Postby gregstewart90 » 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().

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?

tbnobody
Posts: 3
Joined: Mon Aug 14, 2017 12:18 am

Re: [Video] ESP32 - DS1307 real time clock

Postby tbnobody » Mon Aug 14, 2017 12:32 am

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

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: [Video] ESP32 - DS1307 real time clock

Postby kolban » Thu Aug 17, 2017 3:28 am

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.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

musabaybek
Posts: 2
Joined: Sun Aug 04, 2019 11:17 pm

Re: [Video] ESP32 - DS1307 real time clock

Postby musabaybek » Sat Oct 12, 2019 4:04 pm

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?

Who is online

Users browsing this forum: No registered users and 1 guest