https://github.com/ailtonfidelix/ds1307
DS1307 library for ESP-IDF
https://github.com/ailtonfidelix/ds1307
c ds1307 esp-idf esp32 i2c
Last synced: 2 months ago
JSON representation
DS1307 library for ESP-IDF
- Host: GitHub
- URL: https://github.com/ailtonfidelix/ds1307
- Owner: AiltonFidelix
- License: mit
- Created: 2022-09-11T00:16:43.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-07T00:37:23.000Z (over 1 year ago)
- Last Synced: 2025-10-10T16:26:51.422Z (9 months ago)
- Topics: c, ds1307, esp-idf, esp32, i2c
- Language: C
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DS1307 library for ESP-IDF
DS1307 library for ESP32 in the ESP-IDF. In this library the DS1307 module works at 24 hours format.
## How to use
If you are using PlatformIO like me, you can just clone this project in the **lib** folder.
```
cd lib/ && git clone https://github.com/AiltonFidelix/DS1307
```
Otherwise, just copy this project and use however you want.
## Example
```
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
// Include the library
#include
void app_main()
{
printf("Starting ds1307!\n");
// bool true parameter to install the I2C driver
ds1307Begin(true);
// Config date and time
ds1307SetDate(11, 9, 22, 1);
ds1307SetTime(16, 32, 0);
while (1)
{
printf("Hour: %d\n", ds1307GetHour());
printf("Minute: %d\n", ds1307GetMinute());
printf("Second: %d\n", ds1307GetSecond());
printf("Day: %d\n", ds1307GetDateDay());
printf("Month: %d\n", ds1307GetMonth());
printf("Year: %d\n", ds1307GetYear());
printf("Week day: %d\n", ds1307GetWeekDay());
char time[10];
ds1307GetTime(time);
printf("Time: %s\n", time);
char date[10];
ds1307GetDate(date);
printf("Date: %s\n", date);
char timestamp[24];
ds1307GetTimestamp(timestamp);
printf("Timestamp: %s\n", timestamp);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
```
### Author
Created by Ailton Fidelix
[](https://www.linkedin.com/in/ailton-fidelix-9603b31b7/)