DFR0998 / SD3031 RTC - does it work with 3.3V?
Has anyone gotten the DF0998 (with SD3031) to operate with Vdd = 3.3V, the unit i have works fine at 5V, but no I2C communication when running at 3.3V or 3.7V.
Any help appreciated.
Hi Jenna.
TL;DR
I produced this entire response and then….
Right down the bottom I provided info from the spec sheet.
And there it is staring me in the face - the I2C bus voltage is specified as 4.5 ~ 5.5 V
So, thank you very much for your offer of help, but it looks like user error → not reading the manual properly!
Though it begs the question - do you know of any other RTCs that operate at 3.3V, that will produce a periodic interrupt?
I've left my response for interest sake.
-----------------------------------------------------------
I am using the Pico Pi W board with minimal configuration/setup.
I have pre-programmed the DFR0998 using an Arduino running at 5V.
So my Pico setup is simply reading the time from the RTC, and outputting to a serial port.
I2C pin connections:
Here's the code for my main routine - my apologies i can't find a way to attach a text file.
#include "stdio.h"#include "pico/stdlib.h"#include "pico/binary_info.h"
#include "hardware/i2c.h"
#include "MyI2CHelper.h"
#define SD3031_IIC_ADDRESS 0x32 ///< Sensor device address#define SD3031_REG_SEC 0x00 ///< RTC Seconds Register#define SD3031_REG_MIN 0x01 ///< RTC Minutes Register#define SD3031_REG_HOUR 0x02 ///< RTC Hours Register#define SD3031_REG_WEEK 0x03 ///< RTC Week Register#define SD3031_REG_DAY 0x04 ///< RTC Day Register#define SD3031_REG_MONTE 0x05 ///< RTC Month Register#define SD3031_REG_YEAR 0x06 ///< RTC Year Register#define SD3031_REG_ALARM_SEC 0x07 ///< RTC Seconds Alarm Register#define SD3031_REG_ALARM_MIN 0x08 ///< RTC Minutes Alarm Register#define SD3031_REG_ALARM_HOUR 0x09 ///< RTC Hours Alarm Register#define SD3031_REG_ALARM_WEEK 0x0A ///< RTC Week Alarm Register#define SD3031_REG_ALARM_DAY 0x0B ///< RTC Day Alarm Register#define SD3031_REG_ALARM_MONNTE 0x0C ///< RTC Month Alarm Register#define SD3031_REG_ALARM_YEAR 0x0D ///< RTC Year Alarm Register#define SD3031_REG_ALARM_CON 0x0E ///< RTC Alarm Control Register#define SD3031_REG_CTR1 0x0F ///< Control Register 1#define SD3031_REG_CTR2 0x10 ///< Control Register 2#define SD3031_REG_CTR3 0x11 ///< Control Register 3#define SD3031_REG_COUNTDOWM 0X13 ///< Countdown Register#define SD3031_REG_TEMP 0x16 ///< Internal Temperature Register#define SD3031_REG_IIC_CON 0x17 ///< I2C Control#define SD3031_REG_BAT_VAL 0x1A ///< Battery Level
#define PIN_SDA 14#define PIN_SCL 15
typedef struct{ uint16_t year; uint8_t month; uint8_t day;// String week; uint8_t hour; uint8_t minute; uint8_t second;} sTimeData_t;
uint8_t bcd2bin(uint8_t val){ return val - 6 * (val >> 4);}
int main(){ stdio_init_all();
gpio_set_function(PIN_SDA, GPIO_FUNC_I2C); gpio_set_function(PIN_SCL, GPIO_FUNC_I2C);
i2c_init(i2c1, 100 * 1000);
uint8_t data = 0; data = 0x80; reg_write(i2c1, SD3031_IIC_ADDRESS, SD3031_REG_IIC_CON, &data, 1);
while (1) { sTimeData_t sTime;
uint8_t buffer[7];
reg_read( i2c1, SD3031_IIC_ADDRESS, SD3031_REG_SEC, buffer, 7);
sTime.year = 2000+bcd2bin(buffer[6]); sTime.month = bcd2bin(buffer[5]); sTime.day = bcd2bin(buffer[4]);
sTime.hour = bcd2bin(buffer[2]&0x7f); sTime.minute = bcd2bin(buffer[1]); sTime.second = bcd2bin(buffer[0]);
printf("%d/%d/%d %d:%d:%d \r\n", sTime.year, sTime.month, sTime.day, sTime.hour, sTime.minute, sTime.second);
sleep_ms(1000); }}
Here's the weird bit:
- using 3.3V from the Pico, or using a 3.7 battery - the time coming back from the RTC is garbage.
- using 5V from a USB port - the time being returned comes good.
Of course, I am using common GND for all of my voltage sources, and only ever connect 1 voltage source to the VCC pin on the RTC at a time.
TBH - I believe the spec sheet is wrong, and the 2.7V specified is for the battery as opposed to a range of voltages. From original SD3031 PDF in Chinese
From PDF out of google translate:
And of course, now that I'm looking at these screen grabs - plain as day it explicitly says I2C voltage is 4.5V ~ 5.5V
william.nardella
Hello,
Regarding your problems of the DFR0998:
1.This module supports 5V power supply, but we found some bugs when testing on the 5V main control board. (The time cannot be obtained after a long time of measurement) So we stipulate that his working voltage is 3.3V.
2.We have not tested this sensor on PICO, but for 3.3V development board, we used ESP32 for testing.You can also temporarily use this sensor on ESP32, and we will arrange related tests of PICO as soon as possible.
3.Please take a look at this product. This module also support 3.3V power supply and could produce a periodic interrupt.
https://www.dfrobot.com/product-2304.html
Hi!
What board are you using? The operating voltage of this product is 3.3V. It should work at this voltage. Could you pls upload the code and wiring diagram? Let's find the problem better.
jenna