erriez / erriezds1307 Goto Github PK
View Code? Open in Web Editor NEWDS1307 RTC (Real Time Clock) library for Arduino
Home Page: https://github.com/Erriez/ErriezArduinoLibraries
License: MIT License
DS1307 RTC (Real Time Clock) library for Arduino
Home Page: https://github.com/Erriez/ErriezArduinoLibraries
License: MIT License
Maybe add:
/*!
Unix epoch time_t seconds since 1970.
*/
time_t ErriezDS1307::getEpoch(struct tm *rdt)
{
time_t t;
// Convert date/time struct tm to time_t
t = mktime(rdt);
// An offset is needed for AVR target
#ifdef ARDUINO_ARCH_AVR
t += UNIX_OFFSET;
#endif
// Return Unix epoch UTC
return t;
}
It helped me to get an automatic RTC update based on Compiled time&date in my application:
if (rtc.read(&rtc_dt))
{
Serial.println("Time fetched from RTC IC....");
}
else
{
Serial.println("Time NOT fetched from RTC IC....");
}
if (rtc.getEpoch(&dt) > rtc.getEpoch(&rtc_dt))
{
// Set new date time
Serial.print(F("Set RTC date time..."));
if (!rtc.write(&dt)) {
Serial.println(F("FAILED"));
} else {
Serial.println(F("OK"));
}
}
And of course no battery yet installed.
Hi, this routine is giving me error in Platform IO for ESP32 Devkit:
...
uint8_t gv_hour;
ErriezDS1307 rtc;
Wire.begin();
Wire.setClock(100000);
if (!rtc.setDateTime(08, 55, 00, 25, 11, 2021, 4)) {
...
invalid digit "8" in octal constant
invalid octal digit
If I set the hour to 8, then the function doesn't work at all and throws error.
Only setting hours from 10-23 works fine.
Same goes for minutes and seconds...
Can you please help me overcome this little issue?
It is not working on esp32 on ports that you mention in the table, maybe there is a slip-up with it. I tested it on Arduino Uno and it works great with the same RTC. With the Example that U posted I get a debug "RTC not found". I'm also not connected to the SQW pin on the RTC, but I think it is not required to just get/set time. It could be my fault but IDK.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.