2016年8月1日 星期一

[Roseapple Pi] Adding RTC to Xapple Pi

For gathering live sensor data and put into SQLite database, it's important to have current time logged with data.

I got DS3231 modules online for around USD$1.5 each. It's designed for Pi using to be easier my life.



According to

Adding a Real Time Clock to Raspberry Pi - Adafruit


I first recompile kernel and adding RTC DS3232 driver as module support since DS3232 is similar to DS3231 except adding SRAM ( it's stupid and waste half day to debug it).

modprobe rtc-ds3232 seems ok, however, attaching it to i2c brought lots of trouble.

echo ds3232 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
and "unable to request IRQ" keeps showing with fifo error

I found someone has similar problem and fix it by patch driver source but I rather like to go simpler way -  to use DS1307 driver instead.

DS1307 is subset of DS3231 without temperature calibration. Everything went through smoothly after using rtc-ds1307.

Another issue I found is that RTC is corrupted every reboot!!! (another waste time here) register 0x06(year) is set to 0x66. Here is a hint that the reason is NTPD. I fix that by disabling ntpd

the quote of the link 
I added to the /etc/ntpd.service file
ExecStartPre=-/usr/bin/hwclock -sExecStartPre=/usr/bin/ntpd -gqand enabled the NTPD service
# systemctl enable ntpdand the date updates and does not corrupt during boot.


However, I found that RTC can be enabled on Raspberry Pi by following this


沒有留言:

張貼留言