====== Micro Crystal RV-3032-C7 on Raspberry Pi ======
{{ ::rv-3032-c7_app-manual.pdf}}
{{ ::rv-3032-c7_datasheet.pdf}}
===== Enable i2c =====
in ''/boot/config.txt'' (or use ''raspi-config'')
''dtparam=i2c_arm=on''
reboot
On a Pi5, also disable the onboard rtc:
''dtparam=rtc=off''
===== Install Requirements =====
''sudo apt-get install python-smbus i2c-tools''
===== Confirm Presence =====
sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
===== Add Overlay =====
to /boot/config.txt
dtoverlay=i2c-rtc,rv3032
reboot
===== Confirm Use =====
sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
====== dmesg ======
$ sudo dmesg | grep rtc
[ 2.837650] rtc-rv3032 1-0051: registered as rtc0
[ 2.839127] rtc-rv3032 1-0051: setting system clock to 2025-02-01T05:17:05 UTC (1738387025)
===== Disable Fake hwclock =====
sudo apt-get -y remove fake-hwclock &
sudo update-rc.d -f fake-hwclock remove &
sudo systemctl disable fake-hwclock
===== Re-Enable Real hwclock =====
edit
sudo nano /lib/udev/hwclock-set
comment these lines:
(7,8, 9)
if [ -e /run/systemd/system ] ; then
exit 0
fi
29:
/sbin/hwclock --rtc=$dev --systz --badyear
32:
/sbin/hwclock --rtc=$dev --systz
reboot
====== Reading the Temperature Sensor ======
The folks that designed the DS3231 were very kind and made the temperature registers user-readable, so we can use it as a thermometer! How neat is that! The temperature is stored in registers 0x11 and 0x12 and is reported in 0.25ºC increments, though keep in mind the sensor is only accurate to ±3ºC. [[https://www.raspberrypi.org/forums/viewtopic.php?t=59808#p956491|This forum post]] includes a sample python script that reads those registers and displays the output. It needs to be run with root privileges, and it will briefly unload the RTC kernel module in order to access the device, though this shouldn't matter given how quickly it runs.
===== Sensors =====
lm-sensors includes a driver that can read the DS3231's temperature sensor. Install the lm-sensors package, then run 'sensors'.
rpi_volt-isa-0000
Adapter: ISA adapter
in0: N/A
cpu_thermal-virtual-0
Adapter: Virtual device
temp1: +31.4°C
rv3032-i2c-1-51
Adapter: Synopsys DesignWare I2C adapter
temp1: +21.3°C
rp1_adc-isa-0000
Adapter: ISA adapter
in1: 950.00 mV
in2: 2.39 V
in3: 1.40 V
in4: 1.43 V
temp1: +36.9°C
===== Directly =====
$cat /sys/class/i2c-dev/i2c-1/device/1-0051/hwmon/hwmon3/temp1_input
21312