Hello everyone in this article we will see different methods to update rtc using ntp server for raspberry so let’s see:
We know that Raspberry Pi does not include any hardware clock on board so It uses internet or net access to set the time with the help of NTP servers. Using the hardware real time clock (RTC) , the Raspberry Pi to be used without internet access and still provide real time services.
Commonly available I2C based RTC IC is DS1307. This IC help you to update Real time in device.
Table of Contents
Hardware Setup for RTC in python:
- Use DS1307 IC
- I2C data and clock lines (SDA and SCL) does not use any pull-up resistors.
- Connect a battery backup to the DS1307.
- Check the connections to the Raspberry Pi.
Software Setup for RTC in python:
Enable i2c on the Raspberry Pi.
Enable i2c module on the Raspberry Pi
Run sudo cd /etc/modprobe.d/raspi-blacklist.conf
Locate the line blacklist i2c-bcm2708 (comment out this module command)
We need to import following modules
Run sudo cd /etc/modules
use this command
i2c-bcm2708
i2c-dev
rtc-ds1307
Next Install i2c-tools
go to python cell and Run
apt-get install i2c-tools
Reboot (It’s only start i2c module )
How to Update RTC Module
How to Initialize the hardware clock
Run i2cdetect -y 0 on Model A
Run i2cdetect -y 1 on Model B
Run i2cdetect -y 0 on Model A
Run i2cdetect -y 1 on Model B
Run hwclock --systohc -D --noadjfile --utc
Above command will set the time on the DS1307.
Run hwclock -r //Verify the hardware clock
Conclusion :
In this article we saw Basic methods to update rtc in raspberry pi so about this article you have any query then free to ask me.