The module stays within the outline of the Raspberry Pi and sits lower than video output so can be easilly installed within most cases. The module is installed directly into the GPIO header pins with no wiring or soldering. Now, the next time you reboot your Raspberry Pi it will read the time from the Real Time Clock.RasClock is a highly accurate real-time clock that plugs directly into the Raspberry Pi and includes a battery backup. Use the following command in a terminal window to check the date is still set: To test this out, shutdown your Raspberry Pi, unplug any ethernet cable or wifi dongle and then turn the Raspberry Pi back on. To save the file, press Ctrl+X, Y then return. Note: If you have a Rev 1 Raspberry Pi, replace i2c-1 by i2c-0 above. Next you will need to add the DS1307 device creation at boot by editing the /etc/rc.local file by running sudo nano /etc/rc.localĪnd add the following lines to the file: echo ds1307 0圆8 > /sys/class/i2c-adapter/i2c-1/new_device In a terminal window run sudo nano /etc/modules and add rtc-ds1307 at the end of the file: You will need to add the RTC kernel module to the file /etc/modules so it is loaded when the Raspberry Pi boots. Making Your Raspberry Pi Use the Real Time Clock The next time you boot your Pi, it will not know that it needs to read the clock from the RTC, so if it is not connected to the internet it will again be showing the wrong time. So, now the RTC clock is set, is that it? Well, no. You can then verify it with sudo hwclock -r: Run sudo hwclock -w to write the system time to the RTC board. ![]() You can check the time using the date command: It will automatically set the time from the network. The easiest way is to connect it up to Ethernet or Wifi. If this is the first time the module has been used, it will report back Jan 1 2000, and you'll need to set the time to the current time. Or if you have the older Rev.1 Raspberry Pi, use: echo ds1307 0圆8 > /sys/class/i2c-adapter/i2c-0/new_deviceĬheck the time on the RTC device using: sudo hwclock -r Now you need to be running as the super user type in: sudo bashĪnd then, if you have a Rev.2 Raspberry Pi or later: echo ds1307 0圆8 > /sys/class/i2c-adapter/i2c-1/new_device The RTC module must be loaded by the kernel by running: sudo modprobe rtc-ds1307 1 Raspberry Pi, you will have to run sudo i2cdetect -y 0 as the I2C bus address changed from 0 to 1 from rev 2 onwards. You should see ID #68 show up (the I2C address of the DS1307 Real Time Clock chip): Turn on the Raspberry Pi and verify that the board is seen by running sudo i2cdetect -y 1 at the command line. You now need to configure your Raspberry Pi to recognise and use the board. Now plug the board onto your Raspberry Pi GPIO pins on the inside corner with the RTC board pointing inwards, as shown below. Always do this using the sudo halt or sudo shutdown -h now commands. It is always best to turn your Raspberry Pi off before plugging anything onto the GPIO pins. ![]() Follow the full instructions, including checking that everything has worked by going through the manual instructions too. Simon Monk has written very good instructions about how to set up your Raspberry Pi to be able to use i2c on the Adafruit site. ![]() The I2C allows the Raspberry Pi to communicate with a lot of different devices at the same time that are also connected to the same I2C pins on the Raspberry Pi. The RTC board uses what is known as the I2C (pronounced 'eye squared see') protocol to communicate between itself and the Raspberry Pi. These inexpensive add-on boards plug on top of your Pi's GPIO pins and contains a clock chip and a tiny battery that tell the Raspberry Pi what time it is. Your Pi has no way of knowing what time it is.īut there is a solution in the form of a 'Real Time Clock' or RTC board. ![]() But what happens if your Pi is not connected to the internet? You're out of luck (or is that time?). When you switch on your PC or Mac, do you have to change its time? Highly unlikely! Do you have to on your Raspberry Pi? Possibly.Įach time your Raspberry Pi boots it connects to what is called an NTP - Network Time Protocol - server and asks it the time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |