PiFace RTC Module

This forum is for topics specific to the Raspberry Pi and Arch Linux ARM

PiFace RTC Module

Postby warlord » Sat Jan 10, 2015 1:39 pm

I'm very new to Arch, but have found it to be much lighter than Rasbian on my Pi B+ So made a transition. But struggled with getting the PiFace RTC working. The install script on the PiFace instructions is for Rasbian so fails to load as it enters the necessary into rc.local - which I understand isn't how Arch works.

So I started figuring out how to do it and thought I'd post how I made it work forme - it may not be the right way, hence my posting here for thoughts and comments.

The modules for the clock need to be enabled by loading them in. I did this by creating a file:

# vi /etc/modules-load.d/piface-rtc.conf
$this->bbcode_second_pass_code('', 'i2c-dev
i2c:mcp7941x
')

Then created the script that activates the rtc

# vi /bin/piface-rtc
$this->bbcode_second_pass_code('', '#!/bin/sh

echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device
hwclock -s')

# chmod +x /bin/piface-rtc

Next I create the service that runs the script and enable it

# vi /etc/systemd/system/piface-rtc.service
$this->bbcode_second_pass_code('', '[Unit]
Description=PiFace RTC (i2c:mcp7941x)
ConditionPathExists=/bin/piface-rtc

[Service]
Type=forking
ExecStart=/bin/piface-rtc
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=no

[Install]
WantedBy=multi-user.target
~
')

# systemctl enable piface-rtc.service

Reboot the Pi and up comes the clock.

You can test it's working with

# timedatectl
$this->bbcode_second_pass_code('', ' Local time: Sat 2015-01-10 13:37:22 GMT
Universal time: Sat 2015-01-10 13:37:22 UTC
RTC time: Sat 2015-01-10 13:37:22
Time zone: Europe/London (GMT, +0000)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2014-10-26 01:59:59 BST
Sun 2014-10-26 01:00:00 GMT
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2015-03-29 00:59:59 GMT
Sun 2015-03-29 02:00:00 BST
')

So let me have some feedback. Did I go the right way? Is there a better/alternative way?
warlord
 
Posts: 6
Joined: Thu Jan 08, 2015 6:54 pm

Re: PiFace RTC Module

Postby pepedog » Sat Jan 10, 2015 2:08 pm

Yes, I would like to tell you about tmpfiles
https://wiki.archlinux.org/index.php/Tm ... rary_files
Create new one in /etc/tmpfiles.d/
No service files or scripts required
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: PiFace RTC Module

Postby warlord » Sat Jan 10, 2015 2:41 pm

Ahh thanks for that. So basically we're cheating by using another service to perform the function for us.

So many ways to skin a cat.
warlord
 
Posts: 6
Joined: Thu Jan 08, 2015 6:54 pm

Re: PiFace RTC Module

Postby pepedog » Sat Jan 10, 2015 7:21 pm

Not really, samba has a tmpfile
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: PiFace RTC Module

Postby warlord » Sat Jan 10, 2015 8:05 pm

Yeah I noticed that. Seems a pretty straight forward way to go. Thanks for the pointer.

I'm often over complicating things until I know better :D
warlord
 
Posts: 6
Joined: Thu Jan 08, 2015 6:54 pm


Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 23 guests