source from
http://thepihut.com/blogs/raspberry-pi-tutorials/17209332-adding-a-real-time-clock-to-your-raspberry-pi
and
https://nicegear.co.nz/blog/using-an-i2c-real-time-clock-rtc-with-a-raspberry-pi/
...
first enable i2c / spi
sudo raspi-config
#Advanced Options => enable Device Tree / SPI / I2C
fix boot
sudo vim /boot/config.txt
#Uncomment
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on
fix modules
sudo vim /etc/modules
#fix to like
snd-bcm2835
i2c-bcm2708
i2c-dev
rtc-ds1307
fix init(hwclock -s = read from DS3231)
sudo vim /etc/rc.local
#add this before exit 0
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -s
date
check blacklist
sudo vim /etc/modprobe.d/raspi-blacklist.conf
#comment spi / i2c module #此處為黑名單,要加上註解,否則無法使用
init hwclock如果你的硬體本身是新的或是要重置(安裝NTPD)(hwclock -w = write to DS3231)
#sudo service ntp stop
sudo ntpd -gq #fix system clock to current time from NTP
sudo hwclock -w #write to hwclock
#sudo service ntp start
memo : load module if not found hwclock
sudo modprobe rtc-ds1307
sudo modprobe i2c-bcm2708
沒有留言:
張貼留言