Hi everybody
I come to you with a question about the RV3028 breakout card
I use it with Pico Explorer
when I start the first time the RTC says
(2000, 1, 1, 5, 0, 0, 6, 0)
when I read with this program
import machine
import time
import RV3028
sda=machine.Pin(20)
scl=machine.Pin(21)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
ds=RV3028.RV3028(i2c)
print(ds.datetime())
the function datetime is in the RV3028 library
*def datetime(self, datetime=None):*
-
"""Get or set datetime"""*
-
if datetime is None:*
-
buf = self.i2c.readfrom_mem(self.addr, DATETIME_REG, 7)*
-
return (*
-
self._bcd2dec(buf[6]) + 2000, # year*
-
self._bcd2dec(buf[5]), # month*
-
self._bcd2dec(buf[4]), # day*
-
self._bcd2dec(buf[3] - self.weekday_start), # weekday*
-
self._bcd2dec(buf[2]), # hour*
-
self._bcd2dec(buf[1]), # minute*
-
self._bcd2dec(buf[0] & 0x7F), # second*
-
0 # subseconds*
-
)*
It reads the first datas in the RTC
%Run -c $EDITOR_CONTENT
(2000, 1, 1, 5, 0, 0, 6, 0) => year, month, day, weekday, hour, minute, seconds
Then I write the actual value of time with this program : (for now time is coded in the program)
import machine
import time
import RV3028
sda=machine.Pin(20)
scl=machine.Pin(21)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
ds=RV3028.RV3028(i2c)
print(ds.datetime())
print (“Ecriture date actuelle”)
# Créer un bloc de data
an = bytearray(7)
an[0]=0 # Secondes BCD
an[1]=0x05 # Minutes
an[2]=04 # Heures
an[3]=5 # Jour de la semaine
an[4]=0x18 # Date
*an[5]=4 # Mois *
an[6]=0x21 # Année
i2c.writeto_mem(0x52, 0, an)
print(ds.datetime())
i2c.readfrom_mem (0x52, 0, 7)
print (“Relecture”)
Ecriture date actuelle (write actual time) year is 2021, month 4…
(2021, 4, 18, 4, 4, 5, 0, 0)
Relecture Then i launch the read program :
%Run -c $EDITOR_CONTENT
(2021, 4, 18, 4, 4, 5, 38, 0)
%Run -c $EDITOR_CONTENT
(2021, 4, 18, 4, 4, 6, 7, 0)
%Run -c $EDITOR_CONTENT
(2021, 4, 18, 4, 4, 8, 11, 0)
You can see when i launch succesive reads seconds grow and then minutes… the clock works well
Now i disconnect the PICO, wait a moment then connect again
Then i read data again on the breakout RV3028
%Run -c $EDITOR_CONTENT
(2000, 1, 1, 5, 0, 0, 5, 0)
What I wrote is gone and we are back to the original settings (January 2000)
I tested the battery : it’s ok Voltage > 1.5v
Do you have an idea ?