Coder Social home page Coder Social logo

erriez / erriezds1307 Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 1.0 1.37 MB

DS1307 RTC (Real Time Clock) library for Arduino

Home Page: https://github.com/Erriez/ErriezArduinoLibraries

License: MIT License

C++ 100.00%
ds1307 rtc library arduino serial terminal i2c examples documentation uno

erriezds1307's People

Contributors

erriez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

m4k3r-org

erriezds1307's Issues

Add a Epoch convert function, so you can easily update the RTC if the time is smaller in RTC then in Compiler Time&Date?

Maybe add:
/*!

  • \brief Convert to Unix UTC epoch time_t
  • \return
  •  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.

Hour 00-09 cannot be set

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?

Not working on ESP32 Lolion32

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.