Showing posts with label RTC. Show all posts
Showing posts with label RTC. Show all posts

Thursday, June 18, 2015

Raspberry pi DS1307 RTC rc.local 스크립트을 올바른 사용방법

DS1307 RTC칩을 i2c로 raspberry pi 에서 사용할 때 주의할점이 있음.

/etc/modules 에 다음을 추가
rtc-1307


/etc/rc.local 에 다음을 추가

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sleep 1
hwclock -s


** Raspberry pi Compute module 또는 2.0 에서는  i2c-1 이고, Raspberry pi 1 모델에서는
i2c-0 임.

** sleep 1  이부분이 중요.
enew_device에 ds1307을 0x68주소로 등록하라고 시킨 후 o/s에서 이를 인식하고 사용하기 까지 약간의 시간이 필요한것 같다. 그래서 sleep 을 줘야함.

hwclock -s 명령이 성공할때도 있고 실패할때도 있었음.



-------------------
If hwclock-s command returens error, use sleep few seconds before "hwclock -s" command.