Then add in /usr/lib/systemd/scripts/ an rtc-setup shell script like thisĮcho ds1307 0圆8 >/sys/bus/i2c/devices/i2c- 1/new_device Description= RTC Clock Setup and Time Sync Before= Type= oneshot ExecStart= /usr/lib/systemd/scripts/rtc-setup WantedBy= multi-user.target Write in /etc/systemd/system/ a rvice file containing the following lines Create and enable rtc-init systemd service: With kernel updates and have to recompile it manually in the future.ġ. Well, laziness apart, I picked it because I didn't want to interfere A good article explaining this can be found here at .Īnother possibility is reading the clock and setting time from user space, and that's what I did, inspired by laziness :D The cleanest solution would be recompiling the kernel with static RTC support. Periodically with Internet time, I've also written a few steps to set up Loading time from the hardware clock at boot and keeping it updated If you want your system to behave like an usual personal computer, If the Pi was connected to the Internet since boot, it should be as easyĪs running hwclock -w.Else read the man page to find out how to set it manually. If you've made it so far, congratulations!Now the hardware clock (RTC) should be synchronized with system clock. Through the I2C interface and read the time stored on it. If everything goes fine the Raspberry should be able to access the RTC Typing a couple of lines in the shell will reveal if the hard work done up to this moment was worth it ) $ echo ds1307 0圆8 > /sys/class /i2c-adapter/i2c- 1/new_device Now power off the Pi, plug the RTC board on the GPIO and power it on again. should be enough I also added the i2c-dev module explicitly.ģ. Create a file /etc/modules-load.d/nf containing i2c-devĪlthough point 1. 3.18 (~ Jan 2015) which introduced Device Tree support. With the Pi running edit /boot/config.txt adding or uncommenting device_tree_param= i2c_arm= on This is the procedure I've followed, using root privileges:ġ. Good, it's now time to connect the Real Time Clock to the raspberry and see what happens. This what I've got in the end and how it looks stacked on the Raspberry Pi B+ You may also find by yourself a good way to solder the header. Look at the pictures for a better description. I soldered the wires to their pins and eventuallyįixed everything with some hot glue, making the board rock solid. IĪlso cut two 2x20 pieces of perfboard and used them to create a solidīase for the header. I used 4 1x10 stacking headers (usually sold for arduino projects)Īnd arranged them into a 2x20, since I couldn't find a cheap 2x20. Using a double side perfboard would probably make things Please note that soldering the four wires to the stacking header will beĪ bit tricky. If you are planning to stack something else on top of the Pi pick a Need to stack something else on the Pi I decided to install a stacking Since the I2C inteface supports multiple devices and I'll probably Optionally you could just connect the four wires to the GPIO without any header. Now solder the header and connect the +5V, GND, SDA and SDL wires to the header. Here's the scheme of the RTC and some pictures showing the process:įirst of all solder the components on the perfboard following theĬircuit diagram above leaving some space for the 2x20 header, which will Check with your requirements if it's accurate enough. Arch Linux ARM already has a kernel module compiled for it.Īnyway drift should be around 20ppm, a couple of seconds per day.it could be easily connected through a I2C interface.required a simple circuitry and few components.my RPi is always connected to the internet, therefore can sync time periodically.I picked a simple DS1307, although not very precise, for many reasons: This tutorial was originally written for a Raspberry B+ running Arch Linux ARM, however you should be able to adapt it to other configurations with few or even no changes. NOTE: The RTC module is compatible with Raspberry A+ / B+ / 2. And you can build it for no more than 8$, instead of buying one for double the price. This is a full Stacking Shield you can elegantly install on top the RPi leaving the GPIO entirely exposed for other devices. Why another "annoying" how to on building a Real Time Clock for the RPi?īecause almost everywhere you find instructions telling you to build the circuit on a breadboard and simply wire it with a couple of loose wires. Difference is mainly in the structure and my article is a bit more verbose. This is a revised and simplified version for made out of this article at my personal blog. If you want to build a good Real Time Clock for your Raspberry here's the tutorial you were looking for!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |