adafruit / RTClib

A fork of Jeelab's fantastic RTC Arduino library
MIT License
794 stars 703 forks source link

add function for ds3231 and problem with strange data #86

Closed Dreamy-Z3r0 closed 5 years ago

Dreamy-Z3r0 commented 6 years ago

I'm currently working with the DS3231 modules as a part of a workshop. I think you may have missed .isrunning() function for DS3231 part when you created the library. Since you have it for DS1307, I've done some copy and paste from DS1307 to DS3231 and it worked. You may find it minor, but this is for some students, so I appreciate if you update the library. Btw, do you know why the data returned when the module is removed is all with 165?

modified library RTClib.zip

drak7 commented 5 years ago

The DS3231 has a lostPower method that is similar. According to the datasheet the DS3231 sets a bit if the oscillator "either is stopped or was stopped for some period," so it sounds like it is always running if it has power but you can detect if it stopped for some reason.

When the module is not connected the result of the Wire read is 0xFF, running that through bcd2bin gives 165.