micropython-Chinese-Community / mpy-lib

HTS221, LPS22, LIS2DW12, LIS2MDL, LSM6DSO, STTS751, si7051, bme280, bmp280, APDS9930, TM1650, TM1637, LCD1602, GNSS, all kinds of micropython drives, examples, libs
MIT License
173 stars 73 forks source link

RTC Calibration #8

Open Gbouna opened 3 years ago

Gbouna commented 3 years ago

Thanks for the library, its been helpful for my application.

I am trying to use your library to get my RTC working with OpenMV Cam H7, I have read about the calibration of RTC which basically set the the RTC time and stores it in the battery-backed memory. So if a backup cell is used the RTC will run accurately in the event of a power outage.

I was wondering how do you I can set the RTC time and store it in the memory with your library. I will appreciate any suggestion on how to do this. Thanks.

shaoziyang commented 3 years ago

Which chip do you use?

Gbouna commented 3 years ago

I am using OpenMV Camera H7.

What I just want to do is to be able to set the RTC time according to the current time and save it to the back up memory so that when there is power outage, the time will still be accurate since the RTC has a back up battery.

Any idea on how to do this will be appreciated

shaoziyang commented 3 years ago

Which RTC chip do you used with OpenMV Camera H7?

Gbouna commented 3 years ago

I am using DS3231

shaoziyang commented 3 years ago

DS3231 use registry 10h to calibration RTC (Aging Offset). I didn't implement the calibration function alone, but you can use setReg function to calibration RTC, such as:

ds = DS3231.DS3231(i2c)
ds.setReg(0x10, val)

image