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.
User avatar
By j1s1
Dear Mark,

thank you for your feedback, most appreciated!

The libraries you have referenced are the ones I am using as "guideline", still without luck though.

You have any contact details to vendor tech-support for this?

Anyway, thank you for replying! :)

Best Regards,
Kristian H Jensen
User avatar
By j1s1
Hi Mark,

NB: I made a rookie mistake left shifting the I2C address by one. The I2C read and write addresses given in the documentation are the full 8bit read/write address, not the 7bit.
Code: Select all
#define RTC_Address 0xD2
#define RTC_AddressRead  (RTC_Address << 1) | 0x01 //ERROR --> Shall not be left shifted, as 0xD3 is itself the 8bit Read Address to use
#define RTC_AddressWrite (RTC_Address << 1) | 0x00  //ERROR --> Shall not be left shifted, as 0xD2 is itself the 8bit Write address to use          

Everything worked nicely once I figured this out.

Thank you for your feedback!

Kristian H Jensen