SparkFun Forums 

Where electronics enthusiasts find answers.

Questions &/or issues related to products in the Qwiic category should be posted in this forum. To learn more about Qwiic, consider checking out our pillar page on the Qwiic system.
User avatar
By j1s1
Dear Sparkfunners,

I am interfacing an RV1805-CW I2C (qwiik) wiring from an Atmega328p MCU, however I am not able to get "sensible" readings back. I know that my I2C interface is working, as I am getting sensible readings back from my tmp102 temperature module which is on the same TWI bus (also qwiiic).

When accessing the 0x28 register to get the "part nr" back from the RV1805, I should get back: 0x00011000 = 0x18 = 24 decimal (ref datasheet). However, ref attached snippet, I get 165 (decimal) back.

Below you will see the C code I am using to poll the part nr back from the module.

Are there any required "initialization routine" I will have to perform towards the RV1805 module in order to get it to work properly? Or, do you see any obvious error in my below c-code?

// --------------------------------------
Code: Select all
#define RTC_Address 0xD2
#define RTC_AddressRead  (RTC_Address << 1) | 0x01
#define RTC_AddressWrite (RTC_Address << 1) | 0x00
#define RV1805_ID0 0x28

uint8_t RTC_ReadPartNr() {
uint8_t ans;

sRTC_Status.uint8t_Status = TWI_write_address(RTC_AddressWrite);
sRTC_Status.uint8t_Status = TWI_write_data(RV1805_ID0); //Reads addr 0x28 (Part Nr Upper Register - BCD format) - Should return 00011000 = "18" in BCD or 24 decimal. 
sRTC_Status.uint8t_Status = TWI_read_address(RTC_AddressRead);
ans = TWI_read_data_Nack2(); //0x28 - PartNr Upper Register BCD Format (Should return "18" in BCD format - 00011000 = 24 decimal)
return ans; //ans returned value gives me this 0b10100101 = 165 decimal
Hoping anyone can help! :)

Kristian Holm Jensen
Hello Kristian,

Unfortunately, SparkFun Tech Support cannot help debug custom code but I can try to point you to a couple of resources that may help you troubleshoot this issue. Here is a link to the RV1805 Begin Function from our Arduino Library. The header file might also help you out here.

If possible, try using the Qwiic RTC with an Arduino and our examples to make sure your RTC is working properly.