# RV3028 and Raspberry Pi Pico

**URL:** <https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914>\
**Category:** Support\
**Created:** [April 18, 2021, 3:20pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914 "2021-04-18T15:20:16Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![framboise314](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/framboise314/32/7802_2.png) [@framboise314](https://forums.pimoroni.com/u/framboise314)\
**Post date:** [April 18, 2021, 3:20pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/1 "2021-04-18T15:20:16Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 18, 2021, 5:01pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/2 "2021-04-18T17:01:54Z")

</div>

I got lost a bit in what you posted but I’ll chime in on my experience with that breakout on a Pi. It’s my understanding that the backup battery isn’t enabled out of the box. If you look at the set-time.py file it states the following.  
print("""set-time.py - Sets RTC with current time for your system and  
enables battery backup to preserve the time when power is off.  
I’ve used several of these on Raspberry Pi’s. I do the `sudo pip install rv3028` then run the set-time.py and get-time.py. Then do my normal RTC setup stuff.  
Have a look at the set-time.py file  
[rv3028-python/set-time.py at master · pimoroni/rv3028-python · GitHub](https://github.com/pimoroni/rv3028-python/blob/master/examples/set-time.py)  
I think you need to do the equivalent to  
`rtc.set_battery_switchover('level_switching_mode')`  
It may be easier to just connect it to a Raspberry Pi and run the set time. As far as I know you only have to do this once.

---

<div class="post-metadata">

**Author:** ![framboise314](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/framboise314/32/7802_2.png) [@framboise314](https://forums.pimoroni.com/u/framboise314)\
**Post date:** [April 18, 2021, 6:43pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/3 "2021-04-18T18:43:08Z")

</div>

Thank you !  
OK i understand i only have breakout on pico explorer but i will connect the bord on pi and try it !  
Many thanks 🙂

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 19, 2021, 12:14am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/4 "2021-04-19T00:14:09Z")

</div>

On a sort of side note, I do believe the PICO have an onboard RTC. No battery backup for it though, so you’d have to have reliable 24/7 power or run the PICO on battery. The new PICO LIPO Shim may fit the bill?  
[LiPo SHIM for Pico – Pimoroni](https://shop.pimoroni.com/products/pico-lipo-shim)  
I have one on order so I may be testing this out at some point.  
If you get yours working please share your code. =)

I’m also wondering if the onboard one is maybe messing things up for you?

---

<div class="post-metadata">

**Author:** ![framboise314](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/framboise314/32/7802_2.png) [@framboise314](https://forums.pimoroni.com/u/framboise314)\
**Post date:** [April 19, 2021, 9:14am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/5 "2021-04-19T09:14:59Z")

</div>

Hello  
yes indeed in the RP2040 datasheet the RTC is mentioned in 4.8.  
The idea here is not to make the Pico work 24/24h but to implement breakout cards or other components in I2C.  
In this example I have a BME680 sensor in the breakout1 slot which I access in micropython to read the information and then display it on the Pico Explorer screen. This works. I would now like to integrate this RV3028 RTC card so that when we connect the power to the Pico, it sets the time and displays date+time+climate information.  
The purpose is mainly educational to discover the different Pimoroni breakout boards with MicroPython.  
Thank you for your answers and of course if I have a solution that works it will be online on my blog: [www.framboise314.fr](http://www.framboise314.fr) where I have started to publish articles on Pico. [Vous avez cherché pico - Framboise 314, le Raspberry Pi à la sauce française....](https://www.framboise314.fr/?s=pico)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 20, 2021, 9:01am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/6 "2021-04-20T09:01:58Z")

</div>

Wow, impressive, don’t let me slow you down. =)  
I’ve used a bunch of the Breakout Garden stuff on a Pi. I have several of what I call Weather clocks. They display the Day, Date, Time, Temperature, Humidity and Barometric Pressure in a scrolling message on a Unicorn HD. They have RV3028 RTC’s in them so the date and time is bang on on boot up. Plus one is portable and may not have WIFI to update it on its own. BME280’s mostly. Some also have the light sensor and UV sensor breakouts. Some have the 0.96 LCD breakout and run modified Enviro+ code.

Anyway, long story made short, I want to replicate a lot of that on a PICO. I have the Explorer Pack on the way, I wanted the PICO Breakout Garden but its still listed as coming soon. I’ll be doing something similar in a few weeks, well trying to anyway.

---

<div class="post-metadata">

**Author:** ![Nosferatie](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nosferatie/32/6035_2.png) [@Nosferatie](https://forums.pimoroni.com/u/Nosferatie)\
**Post date:** [April 20, 2021, 4:38pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/7 "2021-04-20T16:38:05Z")

</div>

I’m also keen on this idea using the RV3028 RTC to set the time. Which library did you use? Keep us posted.

---

<div class="post-metadata">

**Author:** ![framboise314](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/framboise314/32/7802_2.png) [@framboise314](https://forums.pimoroni.com/u/framboise314)\
**Post date:** [April 20, 2021, 5:20pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/8 "2021-04-20T17:20:37Z")

</div>

Hi i used rv3038.py for python lib. Now i start from other libs for other rtc but for micropython. I am not full time on it but will publish when i progress

---

<div class="post-metadata">

**Author:** ![Nosferatie](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nosferatie/32/6035_2.png) [@Nosferatie](https://forums.pimoroni.com/u/Nosferatie)\
**Post date:** [April 20, 2021, 7:16pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/9 "2021-04-20T19:16:39Z")

</div>

Ok thanks,

I was just fiddling with this one, works nicely.

> **[x10dit/rv3028\_rtc](https://github.com/x10dit/rv3028_rtc)**
>
> Simple Python class for Pimoroni RV3028 RTC I2C breakout

---

<div class="post-metadata">

**Author:** ![framboise314](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/framboise314/32/7802_2.png) [@framboise314](https://forums.pimoroni.com/u/framboise314)\
**Post date:** [April 21, 2021, 7:29am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/10 "2021-04-21T07:29:11Z")

</div>

Thank you !! i try it today :)

---

<div class="post-metadata">

**Author:** ![Nosferatie](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nosferatie/32/6035_2.png) [@Nosferatie](https://forums.pimoroni.com/u/Nosferatie)\
**Post date:** [April 21, 2021, 7:55am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/11 "2021-04-21T07:55:47Z")

</div>

Seems to hold time, ran my program this morning and clock still correct. :-)

---

<div class="post-metadata">

**Author:** ![framboise314](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/framboise314/32/7802_2.png) [@framboise314](https://forums.pimoroni.com/u/framboise314)\
**Post date:** [April 22, 2021, 1:51pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/12 "2021-04-22T13:51:44Z")

</div>

hi  
it works here too  
thank you :)

```auto
from machine import Pin, I2C
import time
import rv3028_rtc

sda=machine.Pin(20)
scl=machine.Pin(21)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=100000)

rtc=rv3028_rtc.RV3028(0x52, i2c, "LSM")

print (rtc.get_rtc_date_time())
# Valeur actuelle des registres An, mois, date...
date_actuelle = (2021, 04, 22, 15, 37, 0)
rtc.set_rtc_date_time(date_actuelle)

```

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 22, 2021, 2:06pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/13 "2021-04-22T14:06:38Z")

</div>

Just FYI code tags for this forum are three ` before and after your code.  
On my English US keyboard its the key to the left of the 1 key with  
~

That will retain indents etc for you.

---

<div class="post-metadata">

**Author:** ![framboise314](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/framboise314/32/7802_2.png) [@framboise314](https://forums.pimoroni.com/u/framboise314)\
**Post date:** [April 22, 2021, 2:23pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/14 "2021-04-22T14:23:54Z")

</div>

Thank you :) i try to edit…

---

<div class="post-metadata">

**Author:** ![framboise314](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/framboise314/32/7802_2.png) [@framboise314](https://forums.pimoroni.com/u/framboise314)\
**Post date:** [April 25, 2021, 4:38pm UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/15 "2021-04-25T16:38:02Z")

</div>

Hi  
All is now here

> **[Utilisation des BME680 et RV3028 avec Raspberry Pi Pico - Framboise 314, le...](https://www.framboise314.fr/utilisation-des-bme680-et-rv3028-avec-raspberry-pi-pico/)**
>
> J'avais déjà présenté un premier article sur les extensions Pimoroni pour Raspberry Pi PICO. Cette fois je me suis penché sur la carte Pico Explorer que

---

<div class="post-metadata">

**Author:** ![Chas\_Large](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Chas\_Large](https://forums.pimoroni.com/u/Chas_Large)\
**Post date:** [May 10, 2021, 9:49am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/16 "2021-05-10T09:49:39Z")

</div>

Hello, thank you for the PICO MicroPython code. Have tested the RV3028 with I2C Scanner and device is found:

Scanning the i2c bus …  
Component (s) detected : 1  
Address in decimal : 82 | Address in Hexadecimal : 0x52  
But when I run the Clock check/Set I get the following:

Traceback (most recent call last):  
File “”, line 9, in   
File “rv3028\_rtc.py”, line 147, in **init**  
File “rv3028\_rtc.py”, line 371, in \_get  
OSError: [Errno 5] EIO

Can you help?  
I have installed the driver and am using GPIO Pins 8 for data and 9 for CLK.  
Just using PICO on breadboard, not the Pico Explorer like you. ;-)  
Thanks  
Chas  
Many thanks

---

<div class="post-metadata">

**Author:** ![Nosferatie](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nosferatie/32/6035_2.png) [@Nosferatie](https://forums.pimoroni.com/u/Nosferatie)\
**Post date:** [May 10, 2021, 10:10am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/17 "2021-05-10T10:10:31Z")

</div>

Whenever I got EIO error it was an issue with the RV3028 not connected to the Pico. I found with not solering the connectors I would sometimes get EIO errors.

Just check the connectors are 100%.

---

<div class="post-metadata">

**Author:** ![Chas\_Large](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Chas\_Large](https://forums.pimoroni.com/u/Chas_Large)\
**Post date:** [May 10, 2021, 10:21am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/18 "2021-05-10T10:21:48Z")

</div>

Thank you. I reflowed the PIN connections and tried again, et. voilá it now works :)

Odd though that the I2C test worked?

---

<div class="post-metadata">

**Author:** ![Nosferatie](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nosferatie/32/6035_2.png) [@Nosferatie](https://forums.pimoroni.com/u/Nosferatie)\
**Post date:** [May 10, 2021, 11:10am UTC](https://forums.pimoroni.com/t/rv3028-and-raspberry-pi-pico/16914/19 "2021-05-10T11:10:23Z")

</div>

I guess depends on which pin was a cold solder. Glad it worked.
