Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagnosing PiFace-RTC hardware #5

Open
gav- opened this issue Sep 13, 2015 · 15 comments
Open

Diagnosing PiFace-RTC hardware #5

gav- opened this issue Sep 13, 2015 · 15 comments

Comments

@gav-
Copy link

gav- commented Sep 13, 2015

Hi, I can't locate another contact method to obtain hardware support for a PiFace-RTC, so I am posting here. I have been unsuccessful in getting mine to function, most recently attempted on latest raspbian on both a Pi2 B, and an older Pi rev1 B.

The problem is that is impossible to read or write to the RTC, but it does appear to be detected.

root@raspi:/home/pi# tail -n 6 /etc/rc.local 
modprobe i2c-dev
# Calibrate the clock (default: 0x47). See datasheet for MCP7940N
i2cset -y 0 0x6f 0x08 0x47
modprobe i2c:mcp7941x
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device
hwclock -s

root@raspi:/home/pi# hwclock -s
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument

root@raspi:/home/pi# hwclock -w
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Input/output error
hwclock: ioctl(RTC_SET_TIME) to /dev/rtc0 to set the time failed.: Input/output error

root@raspi:/home/pi# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU 
70: -- -- -- -- -- -- -- --                

root@raspi:/home/pi# echo 0x6f > /sys/class/i2c-dev/i2c-0/device/delete_device 
root@raspi:/home/pi# i2cdump -y 0 0x6f b
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: b3 02 01 39 01 01 01 80 47 01 00 00 00 01 01 01    ???9????G?...???
10: 01 03 00 00 01 01 01 01 34 00 01 21 34 00 01 21    ??..????4.?!4.?!
20: ef 31 48 26 38 bc 11 40 25 11 19 86 23 51 46 8d    ?1H&8??@%???#QF?
30: 8d 40 20 07 12 93 99 00 2f 02 09 24 9b ca 02 24    ?@ ????./??$???$
40: 90 a0 4a 21 09 0a 20 4e a0 02 82 39 24 11 a1 1a    ??J!?? N???9$???
50: c4 cc 06 32 00 00 1c 41 36 88 a1 60 42 30 86 40    ???2..?A6??`B0?@
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX    

Any help in diagnosing this issue would be appreciated.

@tompreston
Copy link
Member

Hi,
Sorry it's taken so long to get in touch. Can you remove those lines from your /etc/rc.local, reboot and run the following commands:

$ sudo su
# modprobe i2c-dev
# i2cset -y 0 0x6f 0x08 0x47
# modprobe i2c:mcp7941x
# echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device
# hwclock -r

Use i2c-1 if you're on a Raspberry Pi 2 or above. Do you get a time read out?

@gav-
Copy link
Author

gav- commented May 5, 2016

Thanks for getting back to me, I had all but given up on getting the PiFace RTC to work.

I have checked the RTC battery and it is reading 3.12v between battery positive and pi gnd.

I am testing on a Pi B rev1 (256MB RAM) with a fresh install of latest Raspbian Jessie with I2C enabled (dtparam=i2c_arm=on)

Following your instructions (I had to modprobe i2c-bcm2708 too):

pi@raspi:~ $ sudo su
root@raspi:/home/pi# modprobe i2c-dev
root@raspi:/home/pi# i2cset -y 0 0x6f 0x08 0x47
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory
root@raspi:/home/pi# modprobe i2c-bcm2708
root@raspi:/home/pi# i2cset -y 0 0x6f 0x08 0x47
root@raspi:/home/pi# modprobe i2c:mcp7941x
root@raspi:/home/pi# echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device
root@raspi:/home/pi# hwclock -r
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Invalid argument
root@raspi:/home/pi# ls -la /dev/rtc*
lrwxrwxrwx 1 root root      4 May  5 16:18 /dev/rtc -> rtc0
crw------- 1 root root 254, 0 May  5 16:18 /dev/rtc0
# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 6f 
70: -- -- -- -- -- -- -- --               

@tompreston
Copy link
Member

tompreston commented May 5, 2016

It appears you don't have access to /dev/i2c-0. Maybe you have /dev/i2c-1?

Try running:

ls /dev/i2c-*

To see which I2C devices you have available.

Also, what's the output from:

grep 'Revision' /proc/cpuinfo

Just so I can get the exact revision of your board.

@gav-
Copy link
Author

gav- commented May 6, 2016

I think you may have missed my comment about needing to modprobe i2c-bcm2708, but it was the reason for the error about access to /dev/i2c-0. Please re-check my output, once I insert the module my call to i2cset -y 0 0x6f 0x08 0x47 completes without error.

(I have now removed blacklist i2c-bcm2708 from the /etc/modprobe.d/raspi-blacklist.conf and I don't need to manually modprobe it any more, but the same final issue with failing to read /dev/rtc persists).

Output as requested:

root@raspi:/home/pi# ls /dev/i2c-*
/dev/i2c-0
root@raspi:/home/pi# grep 'Revision' /proc/cpuinfo
Revision    : 0003

@tompreston
Copy link
Member

It's so strange that hwclock doesn't seem to be working even though you get /dev/rtc after loading all of the modules.

Hm, what do you get out of:

# hwclock --debug

I get:

# hwclock --debug
hwclock from util-linux 2.25.2
Using the /dev interface to the clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc does not have interrupt functions. Waiting in loop for time from /dev/rtc to change
...got clock tick
Time read from Hardware Clock: 2016/05/09 13:10:42
Hw clock time : 2016/05/09 13:10:42 = 1462799442 seconds since 1969
Mon 09 May 2016 13:10:42 UTC  -0.791762 seconds

@gav-
Copy link
Author

gav- commented May 11, 2016

It's so strange that hwclock doesn't seem to be working even though you get /dev/rtc after loading all of the modules.

Right. That's been the symptom from day one (tested on different Raspberry Pi hardware), so I've always suspected that the PiFace-RTC was DOA.

The command echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device, shows the following in dmesg:

[  106.413544] rtc-ds1307 0-006f: SET TIME!
[  106.415192] rtc-ds1307 0-006f: SET TIME!
[  106.418350] rtc-ds1307 0-006f: rtc core: registered mcp7941x as rtc0
[  106.418415] rtc-ds1307 0-006f: 64 bytes nvram
[  106.418484] i2c i2c-0: new_device: Instantiated device mcp7941x at 0x6f

So /dev/rtc is created as expected, but hwclock always fails. Debug output as requested:

root@raspi:/home/pi# hwclock --debug
hwclock from util-linux 2.25.2
Using the /dev interface to the clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc does not have interrupt functions. Waiting in loop for time from /dev/rtc to change
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Invalid argument
...synchronization failed

@ambrosa
Copy link

ambrosa commented Aug 9, 2016

Hi Guys.

Same problem here.
I've just bought a PiFace Clock and I've installed into an old RPI model A (256MB RAM) with bus i2c-0
A Raspbian Jessie Lite fresh installation.

PiFace Clock module has worked fine for about 30 minutes.

Then after a reboot
root@Pi:~# hwclock -r
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Invalid argument

root@Pi:~# hwclock --debug
hwclock from util-linux 2.25.2
Using the /dev interface to the clock.
Last drift adjustment done at 1470768579 seconds after 1969
Last calibration done at 1470768579 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc does not have interrupt functions. Waiting in loop for time from /dev/rtc to change
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Invalid argument
...synchronization failed

Very strange. Ant it not worked any more. I've removed the battery CR1220, I've reinserted the PiFace Clock module. Nothing. It doesn't work anymore.
Dead ?

@ambrosa
Copy link

ambrosa commented Aug 9, 2016

dmesg looks to be correct

[ 7.911265] bcm2708_i2c 20205000.i2c: BSC0 Controller at 0x20205000 (irq 77) (baudrate 100000)
[ 10.986294] rtc-ds1307 0-006f: SET TIME!
[ 10.987901] rtc-ds1307 0-006f: SET TIME!
[ 10.993322] rtc-ds1307 0-006f: rtc core: registered mcp7941x as rtc0
[ 10.993388] rtc-ds1307 0-006f: 64 bytes nvram
[ 10.993501] i2c i2c-0: new_device: Instantiated device mcp7941x at 0x6f

but after that, there are many
[ 18.948852] rtc-ds1307 0-006f: write error -5
[ 19.948834] rtc-ds1307 0-006f: write error -5
[ 20.948846] rtc-ds1307 0-006f: write error -5

@stovalldb
Copy link

Did any of you resolve the PiFace RTC issue? I purchased one some time back and just got back to a project. I need to be able to Date/Time stamp bluetooth pairing. Pi will be offline.
Footnote: just learning Python, last programming experience was with Fortran and Punch Cards, if you say, "what's Fortran or Punch Cards" that was early '70s

@gav-
Copy link
Author

gav- commented Aug 22, 2016

Hi stovalldb,

By the time I confirmed that my PiFace-RTC was dead, I gave up on it. It was unlikely the supplier (Element 14) would give warranty on it by then. I soured on using them after that.

You never mentioned if you have the same problem with yours. If so, contact your supplier.

I was still taught Fortran 77 at University in the early '90s (just without the punch cards).

@stovalldb
Copy link

Gavin,

Thanks for your reply. As mentioned I just re-started a project so pulled out my B and loaded Jessie and installed the PiFace RTC. The instructions on their website using wget didn’t work. So spent a lot of hours just trying to find and get some software installed. Getting ready to order from Amazon: https://www.amazon.com/gp/product/B01AT239Z6/ref=ox_sc_act_title_2?ie=UTF8&psc=1&smid=A2IAB2RW3LLT8D
UCTRONICS DS1307 RTC I2C Real Time Clock Module High Precision for Raspberry Pi 2 model B Arduino by UCTRONICS. Hoping to have better luck with it.

I am trying to replace a gate opener control board that came over on the Mayflower. Will install a Pi at the gate and have my customers pair their smart phones with the Pi using a Key and trip an output to open the gate. Really want to Date/Time stamp the pairing for historical records. The Pi will only be online to access the historical records thru a HotSpot.

Have you tired any other RTC with any success?

David

From: Gavin Stewart [mailto:[email protected]]
Sent: Monday, August 22, 2016 4:20 PM
To: piface/PiFace-Real-Time-Clock [email protected]
Cc: David Stovall [email protected]; Comment [email protected]
Subject: Re: [piface/PiFace-Real-Time-Clock] Diagnosing PiFace-RTC hardware (#5)

Hi stovalldb,

By the time I confirmed that my PiFace-RTC was dead, I gave up on it. It was unlikely the supplier (Element 14) would give warranty on it by then. I soured on the using them after that.

You never mentioned if you have the same problem with yours. If so, contact your supplier.

I was still taught Fortran 77 at University in the early '90s (just without the punch cards).


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #5 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/ATtzWGWXOYIDNUHC8v6ICvLKkeG17deNks5qihKagaJpZM4F8Y6g . https://github.com/notifications/beacon/ATtzWBvBoVBQimmfmco98CKeJnTA-19Bks5qihKagaJpZM4F8Y6g.gif

@stovalldb
Copy link

Gavin,

Is the Raspberry Pi a hobby or do you make a living programming?

David

From: Gavin Stewart [mailto:[email protected]]
Sent: Monday, August 22, 2016 4:20 PM
To: piface/PiFace-Real-Time-Clock [email protected]
Cc: David Stovall [email protected]; Comment [email protected]
Subject: Re: [piface/PiFace-Real-Time-Clock] Diagnosing PiFace-RTC hardware (#5)

Hi stovalldb,

By the time I confirmed that my PiFace-RTC was dead, I gave up on it. It was unlikely the supplier (Element 14) would give warranty on it by then. I soured on the using them after that.

You never mentioned if you have the same problem with yours. If so, contact your supplier.

I was still taught Fortran 77 at University in the early '90s (just without the punch cards).


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #5 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/ATtzWGWXOYIDNUHC8v6ICvLKkeG17deNks5qihKagaJpZM4F8Y6g . https://github.com/notifications/beacon/ATtzWBvBoVBQimmfmco98CKeJnTA-19Bks5qihKagaJpZM4F8Y6g.gif

@gav-
Copy link
Author

gav- commented Aug 23, 2016

If your issue is different to mine (and it sounds like it might be), then I would strongly suggest you open a new issue about it, and include details about the commands you have used, including the errors you are seeing.

I haven't used any other RTC with the pi, so I can't suggest one.

Yes, I write software for a living, but I only use the Raspberry Pi in a hobby capacity (for the moment anyway).

@stovalldb
Copy link

The first issue was the instructions from PiFace for the download don’t work. The link is wrong. All your posts helped some but being a beginner was just a little over my learning curve right now. I will continue to work on my Bluetooth side of the project and come back to the RTC later.

From: Gavin Stewart [mailto:[email protected]]
Sent: Monday, August 22, 2016 7:13 PM
To: piface/PiFace-Real-Time-Clock [email protected]
Cc: David Stovall [email protected]; Comment [email protected]
Subject: Re: [piface/PiFace-Real-Time-Clock] Diagnosing PiFace-RTC hardware (#5)

If your issue is different to mine (and it sounds like it might be), then I would strongly suggest you open a new issue about it, and include details about the commands you have used, including the errors you are seeing.

I haven't used any other RTC with the pi, so I can't suggest one.

Yes, I write software for a living, but I only use the Raspberry Pi in a hobby capacity (for the moment anyway).


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #5 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/ATtzWP02q9BzpnDvOA4C3aN3QyWEmimxks5qijsmgaJpZM4F8Y6g . https://github.com/notifications/beacon/ATtzWIZwABA_ZGjk7h3iODXPGiByo9h6ks5qijsmgaJpZM4F8Y6g.gif

@fc-gituser
Copy link

Dear Sir, I have been trying to install PiFace Real Time Clock on a Raspberry Pi Zero (Jessie distribution) for a number of months but have been unsuccessful. I have many of these devices and would llike to install them on RPi Model 3 as well when issues are resolved. I had installed a number of these devices over a year ago through /etc/rc.local but now that a new revision is out using /etc/init.d/ pifacertc these devices are just not identified the "6f" code is shown and when the driver is loaded it shows the "UU". However, a vast number of attempts of invoking sudo ./install-piface-real-time-clock.sh results in a message which states that an additional init script needs to be created but never is explained or described in detail. All variations of code developed and tried in an element14 community discussion- https://www.element14.com/community/message/207318/l/re-installing-code-for-piface-real-time-clock#207318 - results in " Failed to install the PiFace RTC. It may be that the install script in raw.github.com/piface/PiFace-Real-Time-Clock does not test for RPi ZERO's.
In any event, below is the entire discussion of the issue I have been confronted with and unfortunately I do not had enough knowledge to resolve the issue.

Installing Code for PiFace Real Time Clock

This question is Not Answered.(Mark as assumed answered)

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Oct 11, 2016 4:52 AM

Dear Element 14 Community.

All my Raspberry Pi devices (RPi 2, RPi Zero, and RPi 3 (planned) are running with the current Raspbian Jessie version. I have successfully installed PiFace Real Time Clock using the PiFace website instructions and GitHub.com software download on a number of RPi 2's and one of my three RPi Zero's.

I have recently continued the installations on another two RPi's and cannot continue because after these two lines:

  1. chmod +x install-piface-real-time-clock.sh
  2. sudo ./install-piface-real-time-clock.sh

The following new comments are returned: 1

1.. create new pifacertc init script to load time from PiFace RTC

  1. Adding /etc/init.d/pifacertc .
  2. install the pifacertc init script
  3. enable I2c by using raspi-config

As I am a Linux beginner, can someone lead me through (expand) the coding of these lines so I may install PiFace RTC currently and in the future. The changelog on GitHub refers to a revision change but I am not knowledgable enough to understand why the install went through previously by not currently.

Thank you very much,

Frank.

I have the same question
Show 0 Likes
(0)

818 Views

Tags (edit)

:
Reply
'

Average User Rating: No ratings (0 ratings)

Average User Rating

No ratings

(0 ratings)

Your Rating:

Rate Poor(1 of 5)

Rate Below Average(2 of 5)

Rate Average(3 of 5)

Rate Above Average(4 of 5)

Rate Exceptional(5 of 5)

'

'

''
4Helpful

Re: Installing Code for PiFace Real Time Clock

Andy Clark (Workshopshed)
Level 8: Tesla

Andy Clark (Workshopshed) Oct 11, 2016 9:51 AM (in response to Frank Caracciolo)

Hi Frank,

looking at that file it appears to be checking if the I2C system is enabled. That's the communications used to talk to the real time clock.

raspi-config is a command line tool for changing the Pi's configuration. You can run that by typing

sudo raspi-config

You can the find the right screen to turn on I2C. It appears to be in the advanced options.
1 of 1 people found this helpful

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Oct 11, 2016 2:09 PM (in response to Andy Clark (Workshopshed))

I thank Andy Clark (Workshopshed) for your speedy reply however the problem still occurs after I2C was enabled at numerous stages of the procedure.

Thank you, Frank

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Michael Conners
Level 7: Edison

Michael Conners Oct 11, 2016 9:55 AM (in response to Frank Caracciolo)

Here was a little post I did about generic I2c and RTC on the Pi

Enabling RTC on the Raspberry Pi 2

Should be the same for the PI3

Mike

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Oct 11, 2016 2:07 PM (in response to Michael Conners)

I thank mconners for your speedy reply however the problem still occurs ater I2C was enabled at numerous stages of the procedure.

Thankyou, Frank

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Michael Conners
Level 7: Edison

Michael Conners Oct 11, 2016 2:13 PM (in response to Frank Caracciolo)

Are you following these instructions?

https://github.com/piface/PiFace-Real-Time-Clock

Mike

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Richard Elkins
Level 6: Lovelace

Richard Elkins Oct 11, 2016 12:09 PM (in response to Frank Caracciolo)

Please note that the /etc/init.d folder is for the use of system service platforms like Upstart and Systemd (latest). I would not put a script there. If you want some low-level service to automatically start during the Linux boot process, the file /etc/rc.local is a better place to do this (somewhere before the exit command that is delivered in the installed rc.local). On the other hand, I cannot see the "GitHub.com software" you are talking about because you didn't mention the URL. Please publish this.

This one?

https://github.com/jhowie/FreeBSDPiFaceRTC

That one states to put the start up command in rc.local (good advice).

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Oct 11, 2016 2:25 PM (in response to Richard Elkins)

Dear texadactyl

I just now saw your referral to another website I can try and I will do so in the net hour. I don't now if this will be successful. I've never seen this on the web and it appears that I'll have to learn- not knowing what BSD means right now. I'd appreciate your comment about using this method instead of the one descibed below.

But as to your comment " I cannot see the "GitHub.com software" you are talking about, here is the following:

Starting Website to Add PiFace Real Time Clock
http://www.piface.org.uk/products/piface_clock/

Two Links (located towards bottom of site) were followed:

  1. Documentation (downloaded pdf File)
  2. PiFace Real Time Clock on GitHub
    https://github.com/piface/PiFace-Real-Time-Clock

Restating the issue
Previous installations of PiFace RTC on both RPi 2 and RPi Zero following the procedure listed above have worked successfully.

Currently, during the installation of additional RPi Zero devices. I ran into a problem which prevented me to continue.
After the command:

chmod +x install-piface-real-time-clock.sh

no problem was rncountered. However after I added:

sudo ./install-piface-real-time-clock.sh

The following four lines were returned:

create new pifacertc init script to load time from PiFace RTC
Adding /etc/init.d/pifacertc .
install the pifacertc init script
enable I2c by using raspi-config
(and also suggestions as how to inable I2C.

Within https://github.com/piface/PiFace-Real-Time-Clock, the changemod lists two versions (revisions): v0.2.0 which involves /etc/init.d/pifacertc script and v0.1.0 which involves the /etc/rc.local script. I thoroughly agree that rc.local is the best "option" since this is the path that worked in the past (I guess).

As I am a Linux beginner, is there any method to select or "grab" the first version or, solving the present issue, can someone give me the line-by-line coding of the first two lines which involve the script creation so I may install PiFace RTC in the future. This is the one you have not recommended.

Ill be glad to explain further if there still is a miscommunication on my part.
Frank.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Richard Elkins
Level 6: Lovelace

Richard Elkins Oct 11, 2016 3:56 PM (in response to Frank Caracciolo)

I didn't mean that using an /etc/init.d/x script was invalid; it just runs the risk of becoming inoperative in the future if the service manager changes. That is why user-level applications should avoid infrastructure folders unless they are willing to provide a methodology and documentation for each service manager in use by Unix and Linux. I have done this too so I am no angel.

"BSD" usually refers to University of California at Berkeley Unix as late as the 1980s, a precursor to Linux and MacOSX (based on BSD 4.4).

Okay, I have seen the script. It looks clearly written and very modular although it only provides a service start function (no stop or reload). I'll stop being picky.

Having tried it myself, I just found out that this script is dependent on the OS being Raspbian. Since I am currently running Ubuntu MATE on my Raspberry Pi, I could not go further. It fails for me when it correctly diagnoses that the raspi-config service is missing. I'll get out of the way and let you get help from folks who are using Raspbian. Sorry that I couldn't be of more help. If you have any general Linux questions, I can help you with that. Maybe, I'll go back to Raspbian when I have a chance in the future.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Oct 11, 2016 6:49 PM (in response to Frank Caracciolo)

Are those all of the comments that are returned? Having a glance at the install script it seems there should be a piece saying to reboot and another demonstrating how to set the clock etc... If these are missing it would indicate that the install script has not completed correctly.

Has the install script created the /etc/init.d/pifacertc file? check by typing cat /etc/init.d/pifacertc into a terminal window, there should be around 37 lines of text print out into the terminal as a result.

If the installer hasnt completed succesfully it should be easy enough to replicate the procedure manually, everything is provided in that script to do that.

p.s.the comments 1,2 and 3 that appear ate just the install script telling you where it is up to. Comment 4 is an instruction to you to run raspi-config, as I said above, there should also be more text below this
2 of 2 people found this helpful

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Oct 12, 2016 2:48 PM (in response to lucie tozer)

Thanks for the response of the many users over the last 48 hrs.
Dear lucie tozer:

Let me respond directly to your suggestion:

I opened the /etc/init.d/pifacertc file in from the File Manager
and typed cat /etc/init.d/pifacertc at the terminal.
Both ways yielded:

!/bin/sh

BEGIN INIT INFO

Provides: pifacertc

Required-Start: udev mountkernfs $remote_fs raspi-config

Required-Stop:

Required-Start: S

Default-Stop:

Short Description: Add the PiFace RTC

Description: Add the PiFace RTC

END INIT INFO

. /lib/lsb/init-functions

case "$1" in
start)
log_success_msg "Probe the i2c-dev"
modprobe i2c-dev
# Calibrate the clock ( default: 0x47). See datasheet or MCP7940N
log_success_msg "Calibrate the clock"
i2cset -y 0x6f 0x08 0x47
log_success_msg "Probe the mcp7941x driver
modprobe i2c :mcp7941x
log-success-msg "Add the mcp7941x device in the sys filesystem"
#https://www.kernel.org/doc/Documentation/i2c/instantiating-devices
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-0/device/new_device
log-success-msg "Synchronise the system clock and hardware RTC"
hwclock --hctosys
;;
stop)
;;
restart)
;;
force-reload)
;;
#)
echo "Usage: $0 start" >&2
exit 3
;;
esac

I opened the /etc/init.d/rc.local file in from the File Manager
and typed cat /etc/init.d/rc.local at the terminal.
Both ways yielded:

!/bin/sh

BEGIN INIT INFO

Provides: rc.local

Required-Start: $ all

Required-Stop:

Required-Start: 2 3 4 5

Required-Stop:

Short Description: Run /etc/rc.local if it exist

END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin

./lib/init/vars.sh
./lib/lsb/init-functions

do_start () {
if [ -x /etc/rc.local ]; then
[ "$VERBOSE" !=no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
/etc/rc.local
ES=$?
[ "$VERBOSE" !=no ] && log_end_msg $ES
return $ES
fi
}
case "$1" in
start )
do_start
;;
restart | reload | force-reload)
echo "Error: argument "$1" not supported" >&2
exit 3
;;
stop | status )
# No-op
exit 0
;;
*)
echo "Usage: 0 start|stop" >&2
exit 3
;;
esac

I appreciate you speedy response to continue with my problem. To re-summarize my total experience with Installing the PiFace Real Time Clock here's additional, more-specific information.

I had successully installed previous RPi 2's and one of my RPi 0's all running the current Rasbian Jessie software following these websites:

Starting Website to Add PiFace Real Time Clock
http://www.piface.org.uk/products/piface_clock/

Two Links (located towards bottom of site) were followed:

  1. Documentation (downloaded pdf File)
  2. PiFace Real Time Clock on GitHub
    https://github.com/piface/PiFace-Real-Time-Clock

The previous installation on a RPi Zero (which was successfull) did not generate a /etc/init.d/pifacertc file
and during the boot phase, I did see a line:
[Failed (in red): Failed to start /etc/rc.local compatibility.
but evidently the clock installed correctly.
The text for the rc.local files on this device and the RPi Zero device that failed are identical.

My PATH to install on the failed device is briefly described next:

pi@raspberrypi ~$ ls
Downloads (among other files)
pi@raspberrypi ~$ cd Downloads
install-piface-real-time-clock.sh (in bold yellow/green color)
chmod +/ install-piface-real-time-clock.sh (returns prompt)
sudo ./install-piface-real-time-clock.sh (problems occur)
returns:
Create a new pifacertc init script to load time from PiFace RTC
Adding /etc/init.d/pifacertc .
Install the pifacertc init script
Enable I2C by adding:

raspi-config

then navigate to "Advanced Options" > I2C
and select 'yes' to enable the ARM I2C interface. Then reboot ans set the clock with:

sudo date -s "10 JAN 2014 10:10:30"
sudo hwclock --systohc
Downloads $

(end of PATH return)

I type the command:
sudo reboot.
During the boot phase, I noted the following 2 lines:

[FAILED] Failed to start LSB: Add the PiFace Device
See "systemct1 status pifacertc service" for details

In fact, I have configured another RPi Zero device in a separate electrical system and tried the install and the same failure occurs.

This begs two questions:

  1. How to Run command to "See systemct1 status pifacertc service for details" and
  2. Relative to the long-winded response from the terminal after the sudo ./install ... command (PATH above), what should the new pifacertc script contain, why add another /etc/init.d/pifacertc . , and how to install it. It does not detail any of these returns. Finally, you have indicated that the install script may not have completed correctly. Based on all of the above, did the script complete successully or do I need to create another script of which Iis unknown to me.

Dear lucie tozer:

If you've arrived here without abandoning me I appeciate it. I just don't understand why an installation can proceed in entirely two different paths on identical systems but yielding different file structures. I'm sure its my mistake and I am confident I'll find the solution through your and many others help. Thanks again. Frank

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Clem Martins
Level 9: Hertz

Clem Martins Oct 12, 2016 2:56 PM (in response to Frank Caracciolo)

Swap SD cards and if the problem moves, then the problem is on that card and is not identical!

Clem

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Oct 12, 2016 4:48 PM (in response to Frank Caracciolo)

Looking at the rest of the scripts output you just posted, it would appear that the installer did complete successfully, have you checked to see if the service is enabled sudo systemctl is-enabled pifacertc or you could try to find it in the list of services sudo systemctl -a even just trying to start the service manually might give some clues if it returns an error sudo systemctl start pifacertc

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 5, 2016 2:29 PM (in response to lucie tozer)

Dear Ms. Tozer

After attempting to get PiFace Real Time Clock to install on Raspberry Pi Zero over the last two months, I've to the possibility that the INSTALL PROGRAM at: http://github.com/piface/PiFace-Real-Time-Clock does not address the Zero Model. The following is an extraction from the install code:

#=======================================================================

NAME: start_on_boot

DESCRIPTION: Load the I2C modules and send magic number to RTC, on boot.

#=======================================================================
start_on_boot() {
echo "Create a new pifacertc init script to load time from PiFace RTC."
echo "Adding /etc/init.d/pifacertc ."

if [[ $RPI_REVISION == "3" ]]; then
    i=1  # i2c-1
elif [[ $RPI_REVISION == "2" ]]; then
    i=1  # i2c-1
else
    i=0  # i2c-0
fi

cat > /etc/init.d/pifacertc  << EOF

(end of code)

Are these revisions referring to Software Revisions 2 and 3 or the Hardware Models 2 and 3 ?

Does anyone know if Piface RTC can be installed on to a RPi ZERO model or not. ?

Sorry for the persistence in my requests to you and the community but I'm running out of ideas but not patience.

Am I am able to accomplish this task or not.

Thank you.

PS. The commands that you suggested,, such as:

sudo systemctl is-enabled pifacertc

sudo systemctl -a

sudo systemctl start pifacertc

all return the statements "PiFace RTC "not added, "failed to be added", "cannot be started" or generally notfound.

Thanks for your help and hope someone out there will continue to respond.

Frank

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Peter Oakes
Level 8: Tesla

Peter Oakes Nov 5, 2016 4:10 PM (in response to Frank Caracciolo)

A word on PI Revisions

if you run the command " cat /proc/cpuinfo" you will get a bunch on information returned including the revision value

Here is what I get on a Quark 1000 based Intel Galileo

processor : 0

vendor_id : GenuineIntel

cpu family : 5

model : 9

model name : Quark SoC X1000

stepping : 0

cpu MHz : 399.088

cache size : 16 KB

fdiv_bug : no

f00f_bug : no

coma_bug : no

fpu : yes

fpu_exception : yes

cpuid level : 7

wp : yes

flags : fpu vme pse tsc msr pae cx8 apic pbe nx smep

bugs :

bogomips : 798.17

clflush size : 32

cache_alignment : 32

address sizes : 32 bits physical, 32 bits virtual

power management:

if I run this on a PI i get this

processor : 0

model name : ARMv7 Processor rev 4 (v7l)

BogoMIPS : 76.80

Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32

CPU implementer : 0x41

CPU architecture: 7

CPU variant : 0x0

CPU part : 0xd03

CPU revision : 4

processor : 1

model name : ARMv7 Processor rev 4 (v7l)

BogoMIPS : 76.80

Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32

CPU implementer : 0x41

CPU architecture: 7

CPU variant : 0x0

CPU part : 0xd03

CPU revision : 4

processor : 2

model name : ARMv7 Processor rev 4 (v7l)

BogoMIPS : 76.80

Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32

CPU implementer : 0x41

CPU architecture: 7

CPU variant : 0x0

CPU part : 0xd03

CPU revision : 4

processor : 3

model name : ARMv7 Processor rev 4 (v7l)

BogoMIPS : 76.80

Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32

CPU implementer : 0x41

CPU architecture: 7

CPU variant : 0x0

CPU part : 0xd03

CPU revision : 4

Hardware : BCM2709

Revision : a02082

Serial : 00000000a1243900

You can see the repeated parts for the 4 processor cores but also the revision statement near the end, you can see this does not match any of the test statements that simply expect a 2 or 3.... the reason for this is that Raspberry PI's made by sony have the 2, 3 style revision numbers, but the PI's made by Embest have the style above "a02082",

now this also seems to have moved to the later style for both. here is a table I found

Revision

Release Date

Model

PCB Revision

Memory

Notes

Beta Q1 2012 B (Beta) ? 256 MB Beta Board
0002 Q1 2012 B 1.0 256 MB
0003 Q3 2012 B (ECN0001) 1.0 256 MB Fuses mod and D14 removed
0004 Q3 2012 B 2.0 256 MB (Mfg by Sony)
0005 Q4 2012 B 2.0 256 MB (Mfg by Qisda)
0006 Q4 2012 B 2.0 256 MB (Mfg by Egoman)
0007 Q1 2013 A 2.0 256 MB (Mfg by Egoman)
0008 Q1 2013 A 2.0 256 MB (Mfg by Sony)
0009 Q1 2013 A 2.0 256 MB (Mfg by Qisda)
000d Q4 2012 B 2.0 512 MB (Mfg by Egoman)
000e Q4 2012 B 2.0 512 MB (Mfg by Sony)
000f Q4 2012 B 2.0 512 MB (Mfg by Qisda)
0010 Q3 2014 B+ 1.0 512 MB (Mfg by Sony)
0011 Q2 2014 Compute Module 1.0 512 MB (Mfg by Sony)
0012 Q4 2014 A+ 1.1 256 MB (Mfg by Sony)
0013 Q1 2015 B+ 1.2 512 MB ?
0014 Q2 2014 Compute Module 1.0 512 MB (Mfg by Embest)
0015 ? A+ 1.1 256 MB / 512 MB (Mfg by Embest)
a01040 Unknown 2 Model B 1.0 1 GB Unknown
a01041 Q1 2015 2 Model B 1.1 1 GB (Mfg by Sony)
a21041 Q1 2015 2 Model B 1.1 1 GB (Mfg by Embest)
a22042 Q3 2016 2 Model B (with BCM2837) 1.2 1 GB (Mfg by Embest)
900092 Q4 2015 Zero 1.2 512 MB (Mfg by Sony)
900093 Q2 2016 Zero 1.3 512 MB (Mfg by Sony)
a02082 Q1 2016 3 Model B 1.2 1 GB (Mfg by Sony)
a22082 Q1 2016 3 Model B 1.2 1 GB (Mfg by Embest)

As you can see most current boards don't have what the script is looking for.

To make this work for you, you can modify the script to just work for your board or change it to look for these additional identifiers.

Now technically this should still work even without modification on most latest boards as it will default t I2C-0 if the revision is not matched.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Peter Oakes
Level 8: Tesla

Peter Oakes Nov 5, 2016 5:02 PM (in response to Peter Oakes)

Just realized my PI3 is using an I2C-1, not -0 so it would fail with this script.....

simply run i2cdetect -l to see what is available to you

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 6, 2016 1:13 PM (in response to Peter Oakes)

Dear Mr. Oakes,

In the past 12 hr, I got a couple of responses pertaining to the RPi Zero issue regarding PiFace RTC. I am impressed that so much knowledge can be attained with the cat /proc/cpuinfo command. As I am just a beginner in Raspberry Pi application and its language (I realize its a subset of Linux), I guess I'll call it raspbian language. [A brief history- started with RPi Model 2 / wheezy w/ PiFace RTC all went well but I had to modify the code to use 3.5- and 7- inch raspberry Pi screens. I am into RPi zero Rev 1 installations using Jessie but have had no success in adding PiFace RTC thru /etc/init.d/pifacertc . I plan to install RPi zero Rev 2 with the new Jessie w/ Pixel installation when this issue is resolved. It appears that your suggestions about modifying the code " manualy" but I am very limited knowledgwise in accomplishing the task alone. With the help of ms tozer and now a response from Jan Crumps (please see other posts), I am assuming that a code revision is warranted. I also have RPi 3's planned for installation and hope to find out by then what I'm doing.]

I will execute >> run i2cdetect -l << on my RPi zero's shortly. I see that the only model 512 MB RPi Zero (I assume Ver 1) is a Sony Device. I don't know what my RPi Zero (Ver 2) which includes a camera interface) hardware info and whether the pending changes will be compatible.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Richard Elkins
Level 6: Lovelace

Richard Elkins Nov 5, 2016 4:08 PM (in response to Frank Caracciolo)

See the procedure just above start_on_boot i.e.

#=======================================================================

NAME: set_revision_var

DESCRIPTION: Stores the revision number of this Raspberry Pi into

$RPI_REVISION

#=======================================================================

set_revision_var() {

revision=$(grep "Revision" /proc/cpuinfo | sed -e "s/Revision\t: //")

RPI2_REVISION=$((16#a01041))

RPI3_REVISION=$((16#a02082))

if [ "$((16#$revision))" -ge "$RPI3_REVISION" ]; then

    RPI_REVISION="3"

elif [ "$((16#$revision))" -ge "$RPI2_REVISION" ]; then

    RPI_REVISION="2"

else

    RPI_REVISION="1"

fi

}

It is only recognizing RPi CPUs for hardware models 2 and 3. I cannot see what the "Revision" value at the bottom of /proc/cpuinfo is because I do not have an RPi zero. You might be able to modify these two procedures and make it work.

Whether you are successful or not, I would suggest filing an issue at the github site if you have not yet already done so. It would be great if you can develop a mod for the Pi Zero. Good luck.

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Nov 5, 2016 4:44 PM (in response to Richard Elkins)

Agreed, if the Pi zero doesnt have a compatable revision that the install script can use, it should be easy enough to do the install manually.

Off the top of my head, I think the script was trying to work out the standard i2c port to register the real time clock with, different pi models must have different standard ports i2c-0, i2c-1 etc... I'll have a closer look when theres time unless someone else beats me to it!

If someone finds a way to do it manually, it should be easy enough to make a new script or suggest a modification to the standard script for other people to use.


I can see me having to get a pi zero in the near future (just wish they had onboard wifi...)

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 6, 2016 1:24 PM (in response to Richard Elkins)

Dear Mr. Elkins

I believe that you are spot-on the problem I am having with Installing PiFaceRTC on Rpi Zero (ver 1). Ms Tozer and jan crumps have responded quickly and pointedly at my (and others) issue. I agree on rewriting the code " manually" but I am afraid I am very limited knowledgwise in accomplishing this task alone. I believe that a code revision is imminent and I will patiently await a revision without reporting the bug (I may not be clear of what to request). I just am not knowledgeable to apply the code you wrote above (which is understandable to me) into a executable (I don't know if that's correct verbage) complete code and not know what to do with it. Please read all other posts on this thread because they seem to be very applicable when combined. Thank you very much. Frank.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Richard Elkins
Level 6: Lovelace

Richard Elkins Nov 6, 2016 3:29 PM (in response to Frank Caracciolo)

Frank, you have my permission to call me "Richard" !!

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Nov 6, 2016 6:04 AM (in response to Frank Caracciolo)

Can you enable the i2c port using the raspi-config command and then do ls /dev

You should see either i2c-0 or i2c-1 in the list, could you let us know which one it is please.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Nov 6, 2016 11:12 AM (in response to lucie tozer)

Im going to try and re-write this script, rather than trying to determine the revision of the raspberry pi to workout which i2c port to address,

it can be simplified to ls /dev | grep "i2c" This should get the device directly rather than guessing based on the model.
2 of 2 people found this helpful

Correct Answer'

Helpful Yes | No
Like
Show 2 Likes
(2)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Nov 6, 2016 1:00 PM (in response to lucie tozer)

Here's my revised script, unfortunately I cant test it on a pi zero because I don't have one, nor do I have the real time clock module. The script isn't reliant upon the model or revision of the raspberry pi anymore. It finds the hardware i2c port from the devices list so it should be compatible with all models and revisions of the pi to date. If a raspberry pi is introduced in the future that utilizes multiple i2c ports/buses then this script would need to be modified but for the time being it should work fine.

As a test on my Raspberry Pi 3 Model B, a ran the revised script, restarted and then searched for the MCP7941x device in the i2c-dev system folder, sure enough it was there. If I had the physical realtime clock module, this is the part of the system that would communicate with it.

Sun Nov 6 18:36:48 2016.png

Finally to the revised script:

pifacetest.sh

  • expand sourceview plaincopy to clipboard
    01.#!/bin/bash
    02.#: Description: Enables the required modules for PiFace Clock.
    03.# a modification of a script at:
    04.# https://github.com/piface/PiFace-Real-Time-Clock/blob/master/install-piface-real-time-clock.sh
    05.# this modification includes functionality with Raspberry Pi Zero
    06.# by making the model and revision checking redundant
    07.# credit for the original script goes to tompreston & pat3df at GitHub
    08.# modifications made by Lucie Tozer
  • 10.#=======================================================================
    11.# NAME: check_for_i2c_tools
    12.# DESCRIPTION: Checks if i2c-tools is installed.
    13.#=======================================================================
    14.check_for_i2c_tools() {
  • dpkg -s i2c-tools > /dev/null 2>&1
  • if [[ $? -eq 1 ]]; then
  •    echo "The package `i2c-tools` is not installed. Install it with:"  
    
  •    echo ""  
    
  •    echo "    sudo apt-get install i2c-tools"  
    
  •    echo ""  
    
  •    exit 1  
    
  • fi
    23.}
  • 25.#=======================================================================
    26.# NAME: final_message
    27.# DESCRIPTION: prints instructions for setting the clock
    28.#=======================================================================
    29.final_message(){
  • echo "Now reboot and set your clock with:"
  • echo ""
  • echo ' sudo date -s "14 JAN 2014 10:10:30"'
  • echo " sudo hwclock --systohc"
  • echo ""
    35.}
  • 37.#=======================================================================
    38.# NAME: get_i2c_device
    39.# DESCRIPTION: Obtains the working i2c port from the /dev file system
    40.#=======================================================================
    41.get_i2c_device(){
  • I2C_DEVICE=$(ls /dev | grep "i2c")
  • echo "i2c device on this model = " $I2C_DEVICE
  • if [[ $I2C_DEVICE == "i2c-1" ]]; then
  •    I2C_PORT_NUMBER=1  # i2c-1  
    
  • else
  •    I2C_PORT_NUMBER=0  # i2c-0  
    
  • fi
  • if [[ ! -e /sys/class/i2c-dev/i2c-$I2C_PORT_NUMBER ]]; then
  •    echo "Enable I2C by using:"  
    
  •    echo ""  
    
  •    echo "    raspi-config"  
    
  •    echo ""  
    
  •    echo "Then navigate to 'Advanced Options' > 'I2C' and select 'yes' to "  
    
  •    echo "enable the ARM I2C interface."  
    
  •    echo ""  
    
  •    echo "Please Restart This Script Once The I2C Interface Has Been Enabled"  
    
  •    echo "EXITING..."  
    
  •    exit 1  
    
  • fi
  • 64.}
  • 66.#=======================================================================
    67.# NAME: start_on_boot
    68.# DESCRIPTION: Load the I2C modules and send magic number to RTC, on boot.
    69.#=======================================================================
    70.start_on_boot() {
  • echo "Create a new pifacertc init script to load time from PiFace RTC."
  • echo "Adding /etc/init.d/pifacertc ."
  • cat > /etc/init.d/pifacertc << EOF
    77.#!/bin/sh
    78.### BEGIN INIT INFO
    79.# Provides: pifacertc
    80.# Required-Start: udev mountkernfs $remote_fs raspi-config
    81.# Required-Stop:
    82.# Default-Start: S
    83.# Default-Stop:
    84.# Short-Description: Add the PiFace RTC
    85.# Description: Add the PiFace RTC
    86.### END INIT INFO
  • 88.. /lib/lsb/init-functions
  • 90.case "$1" in
  • start)
  • log_success_msg "Probe the i2c-dev"
  • modprobe i2c-dev
  • Calibrate the clock (default: 0x47). See datasheet for MCP7940N

  • log_success_msg "Calibrate the clock"
  • i2cset -y $I2C_PORT_NUMBER 0x6f 0x08 0x47
  • log_success_msg "Probe the mcp7941x driver"
  • modprobe i2c:mcp7941x
  • log_success_msg "Add the mcp7941x device in the sys filesystem"
  • https://www.kernel.org/doc/Documentation/i2c/instantiating-devices

  • echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-$I2C_PORT_NUMBER/device/new_device
  • log_success_msg "Synchronise the system clock and hardware RTC"
  • hwclock --hctosys
  • ;;
  • stop)
  • ;;
  • restart)
  • ;;
  • force-reload)
  • ;;
  • *)
  • echo "Usage: $0 start" >&2
  • exit 3
  • ;;
    115.esac
    116.EOF
  • chmod +x /etc/init.d/pifacertc
  • echo "Install the pifacertc init script"
  • update-rc.d pifacertc defaults
    121.}
  • 123.#=======================================================================
    124.# MAIN
    125.#=======================================================================
    126.# check if the script is being run as root
    127.if [[ $EUID -ne 0 ]]
    128.then
  • printf 'This script must be run as root.\nExiting..\n'
  • exit 1
    131.fi
  • 135.I2C_PORT_NUMBER=0
    136.I2C_DEVICE=""
  • 138.check_for_i2c_tools &&
    139.get_i2c_device &&
    140.start_on_boot &&
    141.final_message

I kept as much of the original as possible so it should read similarly and changes should be easily noticed.

here's an easy way to install:

  1. copy the script to clipboard

  2. log on to your raspberry pi with a terminal

  3. cd ~/

  4. nano ./pifacetest.sh

  5. Paste clipboard into nano (ctrl + shift + v)

  6. wait a few seconds for nano to buffer the clip board

  7. once clipboard has pasted press ctrl + o to write the file

  8. press ctrl + x to exit nano

  9. sudo chmod +x ./pifacetest.sh to enable the file to be executed

  10. finally run the script sudo ./pifacetest.sh

If your having trouble creating the file, Im happy to upload it to a temporary location so you can use wget to download it directly to the raspberry pi.

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 6, 2016 1:46 PM (in response to lucie tozer)

Dear Ms Tozer,

During the time I was writing the responses to the number of experts I got this message. I truly appreciate the help from all and I will try it on my physical RPi Zeros and PiFace RTC. I don't know whether this will completely install the RTC and as a result it may take a few days (trial and error). However, as you suggested if you can generate a website to expedite the code capture directly to my device terminal, I would greatly appreciate it. In addition, I apologize for not understanding this forums language and you may or may not be attached to "violet" and \or "Jan Cump". (Disregard if you are confused).

Also, as stated in one of Peter Oakes replies, even though the Zero's I've been testing all have the same Mfgr (Sony), I have two other RPi Zeros (model 2- ones a camera interface). I have no knowledge that PiFace RTC will be be successfully installed with your code but I will march on faithfully.

Again all the other replies in this thread should be read for their noble efforts, enthusiasim and participation in this issue.

Thanks again, Frank

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Nov 6, 2016 2:01 PM (in response to Frank Caracciolo)

Ive uploaded the modified file to http://www.uk-robotics.co.uk/temp/pifacertctest.sh provided you pi is connected to the internat, you can download it easily to your raspberry pi by opening a terminal and the typing:

cd ~/

wget http://www.uk-robotics.co.uk/temp/pifacertctest.sh

to run the file type sudo ./pifacertctest.sh

If you have any problem with executable permissions, type chmod +x ./pifacertctest.sh and then try running it again

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Richard Elkins
Level 6: Lovelace

Richard Elkins Nov 6, 2016 3:31 PM (in response to lucie tozer)

"Ms. Tozer",

Suggestion: In the "start" function of /etc/init.d/pifacertc, if an error occurs, quit immediately with the appropriate error message (log_failure_msg). There is no point in continuing with the remaining commands when it isn't going to work. And, it might cause other issues as mentioned in the i2cset man page.

For example, I simulated a clock not connected condition. Actually, I don't have the hardware. I was able to install simply because I enabled i2c in raspy-config.

My syslog entries from system startup:

Nov 6 14:36:02 raspbian pifacertc[1465]: Probe the i2c-dev.

Nov 6 14:36:02 raspbian pifacertc[1465]: Calibrate the clock.

Nov 6 14:36:02 raspbian pifacertc[1465]: Error: Write failed

Nov 6 14:36:02 raspbian pifacertc[1465]: Probe the mcp7941x driver.

Nov 6 14:36:02 raspbian pifacertc[1465]: Add the mcp7941x device in the sys filesystem.

Nov 6 14:36:02 raspbian pifacertc[1465]: Synchronise the system clock and hardware RTC.

Nov 6 14:36:02 raspbian pifacertc[1465]: hwclock: Cannot access the Hardware Clock via any known method.

Nov 6 14:36:02 raspbian pifacertc[1465]: hwclock: Use the --debug option to see the details of our search for an access method.

Nov 6 14:36:02 raspbian systemd[1]: pifacertc.service: control process exited, code=exited status=70

Nov 6 14:36:02 raspbian systemd[1]: Unit pifacertc.service entered failed state.

You can catch the exit code of each step to see if that step was successful or not.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 6, 2016 7:48 PM (in response to lucie tozer)

Dear Ms. Tozer,

I have copied and will act upon the procedure you have clearly and extensively described to me. I will attempt to apply it in the near future. My Many Thanks.

I will also run your suggestion: " Can you enable the i2c port using the raspi-config command and then do:

ls /dev

You should see either i2c-0 or i2c-1 in the list, could you let us know which one it is please."

I hope your suggestions by "Richard" and Peter Oajkes did not cause undo interruptions in your activities. As for your side comments (which I did not follow), I only hope it involves healthy interaction within this friendly community.

Frank

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 7, 2016 1:06 PM (in response to lucie tozer)

Dear Ms Tozer,

I had successfully copied your code into my main folder with : cd~/ and wget instructions.

the pifacertctest.sh was listed and I could open it and see your code.

However, when I typed:

sudo ./pifacertctest.sh

the return was:

sudo: ./pifacertctest.sh :command not found

so I went ahead and typed:

chmod +x ./pifacertctest.sh

the return was:

chmod: cannot access './pifacertctest.sh ': no such file or directory

Am I missing a simple word, command or instruction ?. please comment.

NOTE:

Also I added these commands on the device I was using before (which already had an install-piface-realtimeclock.sh file next to the pifacertctest.sh.)

I did not know if i2c was enabled or if spi was still enabled. I have attached my internet board, an enc28j60, which required enabling spi . A WiPi dongle is also attached.

ADDED NOTE:

Thinking that something was basically wrong, I re-installed a fresh Jessie distribution on the device after deleting all files an re-formatting.

I ran: sudo apt-get update and sudo apt-get upgrade, adjusted time zone and keyboard.through sudo raspi-config.

I am now at the fresh point where I need you to comment on why the system could not find your file . I am sorry for the added problem, your suddestions . . .

frank-Thank you.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Peter Oakes
Level 8: Tesla

Peter Oakes Nov 6, 2016 2:58 PM (in response to Frank Caracciolo)

looking at violet response and new script, it won't matter what the model of PI is, what will matter is if the pi is exposing I2C-0 or I2C-1 and selecting the appropriate one as found in the test

this could easily work on non PI units like ApplePI, OrangePi, BannanaPI etc etc.

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Oct 13, 2016 9:16 AM (in response to Frank Caracciolo)

Dear Ms tozer,

Thanks for your speedy comments and otherwise approaches I had no knowledge of.

No- I did not check these commands but I will do so in the near future. If in fact the installation was successfull, I still am getting a Failed line: Failed to Add PiFace RTC during the boot phase but this may have been resolved within the remaining lines. To be honest when I have a returned response that I must create another init pifacertc script, I may not have proceeded successfully with the date verification and i2c-dev checking. I'll continue to eperiment and thanks or you help. Frank.

Dear Clem Martins,

Thanks or your continuing interest.
Yes- I swapped SD cards and BOTH RPi Zero systems failed. The SD cards are identical in brand, model, and capacity. However, I certainly may have proceeded slightly different in their installations. I should mention that installed on each system are also a WiPi network adapter, a Flash drive, and an ENC28j60 Ethernet module on a poered hub but all these components are performing admirably.

In the future, I may recode Failed SD card from the beginning and install all the components rom scratch again. I would appreciate if you can recommend a specific Rasbpian Jessie version and also comment on the initial commands other than:

sudo apt-get update
sudo apt-get upgrade

In addition, there are a multitude of additional "switches" like, sudo apt-get upgrade -y
What are the current standards that I should use ?

I also plan on cloning the successfull SD card on my windows laptop using notepad ++ and also examining each and every file to determine the differences from the failed SD card. You are certainly correct that something is different with these cards.

Dear Sir, I promise I won't continue bothering you and Ms tozer with these seemingly simple problems
Thans or your consideration.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Jan Cumps
Level 8: Tesla

Jan Cumps Nov 6, 2016 2:54 PM (in response to Frank Caracciolo)

I've seen a few variations of my name floating around in this thread (unusual for a Raspberry Pi topic). What did I say/do?

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Richard Elkins
Level 6: Lovelace

Richard Elkins Nov 6, 2016 3:30 PM (in response to Jan Cumps)

Jan, how can we talk about you behind your back if you keep on peeking over our shoulders???

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Jan Cumps
Level 8: Tesla

Jan Cumps Nov 6, 2016 3:39 PM (in response to Richard Elkins)

tru dat

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Richard Elkins
Level 6: Lovelace

Richard Elkins Nov 6, 2016 3:50 PM (in response to Jan Cumps)

Solve your (tweeted) Windoze 10 problem? Deepest sympathies.

/bin/rm -rf windoze

Correct Answer'

Helpful Yes | No
Like
Show 2 Likes
(2)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Jan Cumps
Level 8: Tesla

Jan Cumps Nov 6, 2016 5:15 PM (in response to Richard Elkins)

I must not be the only one, because a emergency update the day after fixed it.

what I didn't appreciate is that the recovey point mechanism was turned off, and my recovery points (I make one before installing new software) were gone.

Anyways. I work with Linux and Unix on the job and that ain't a dream world eather .

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 6, 2016 7:37 PM (in response to Jan Cumps)

Dear Ms. Jan Cumps,

I apologize for initially brought your name (incorrectly) into this thread. I read the very first line of the thread and didn't realize that you may be the forum administrator overseer. To answer your question, you did not reply, comment or create any post. However, this gives me the opportunity to mention the rapid and accurate responses from this environment.

Thank you Frank.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Peter Oakes
Level 8: Tesla

Peter Oakes Nov 6, 2016 9:44 PM (in response to Frank Caracciolo)

Not an Admin but one of the Evil Minions of the Top Members Guild... even worse , without a master, chaos reigns, Give us a purpose and nothing will get in our way, not even our master

Muhaahaahaahaa

Correct Answer'

Helpful Yes | No
Like
Show 2 Likes
(2)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Jan Cumps
Level 8: Tesla

Jan Cumps Nov 7, 2016 1:28 AM (in response to Frank Caracciolo)

Hi Frank, as Peter says, I'm not and admin here.

And I'm not an RPi expert eather, so if you read something that looks like advice in an RPi thread, and it's written by me, just ignore it .

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 8, 2016 1:00 PM (in response to Jan Cumps)

Dear Jan,

Its a pleasure to meet you. When I learn RPi language, I will looking forward to "moving up" to the more prestigious, "The Complete Linux". Frank.

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Nov 7, 2016 2:02 PM (in response to Frank Caracciolo)

Hah! Thats just linux being pig headed, run the chmod command using sudo like below. The idea being that if a user doesn't have permission to execute a file then the system isnt going to confirm that files existence either so rather than saying permission denied, it just says file not found etc... It discourages repeat attempts at illegally executing files I think!

sudo chmod +x ./pifacertctest.sh

Ive just completed the steps of downloading using wget, then sudo chmod etc.. to test it out and can confirm it does work using sudo!

edit (the below is nothing to do with the question, its just some further reading!!)


The chmod case can be quite confusing, if you are interested here is an explanation why we need to use sudo chmod in this case.

  1. If we use chmod +x ./pifacertctest.sh the file becomes executable for the logged in user, on the raspberry pi that user is called "pi"

  2. We need to execute the file using sudo ./pifacertctest.sh using sudo means we are no longer acting as the user "pi" but we are acting as the user "root" (or with root user privileges)

  3. because the pifacertctest.sh has been made executable for the user "pi" and NOT the user "root" when we try and execute it with root priviliges (sudo), the root user doesn't have the executable permission

  4. if we use sudo chmod +x ./pifacertctest.sh the file becomes executable for the root user, this is because we used sudo

  5. Now the root user has permission to execute the file, its now possible to do with sudo ./pifacertctest.sh

  6. if the script didnt need executing with root privileges (sudo) then we wouldnt have to sudo chmod.
    3 of 3 people found this helpful

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 8, 2016 12:56 PM (in response to lucie tozer)

Dear Ms. Tozer,

You were correct about permissions. The command sudo chmod +x ./install pifacertctest.sh apparently worked. I now have in my /home/pi folder
(in yellow gold)

install-piface-real-time-clock.sh
pifacertctest.sh
(among other files in blue)

The following is a rundown of the command line staements (Input) and replies (Output) within the teminal.

Input: ls /dev
Output: Many files, mostly ram##'s, alot of tty## 's, some vcsa#'s and loop#'s and another dozen.
(None that look like mcpXXXXXXX's ARMyyyyyyyy's or microprocessor names.)

Two positive returns:

Input: ls /dev | grep "i2c"
Output: i2c-1

Input: sudo i2cdetect -l
Output: i2c-1 i2c 20804000.i2c I2C Adapter

Several replies showed failures:

Input: sudo systemctl start pifacertc
Output: (abreviated) Failed to start service, failed to load, and/or not found

Input: sudo systemctl start pifacertctest
Output: (abreviated) Failed to start service, failed to load, and/or not found

Input: sudo systemctl is-enabled pifacertc
Output: (abreviated) Failed to start service, failed to load, and/or not found

Input: sudo systemctl-a
Output: (abreviated) Failed to start service, failed to load, and/or not found

cat /proc/cpuinfo

ARMv7-comp processor rev 7
2.85
half .....
)x41
7
0x0
0xb76
7
BCM2708 (this may be an identifier)
900092 (this may be an identifier)
0000000070ec5112

in your screenshot on one of your replies

Input: /sys/class/i2c-dev/i2c-1/device/new-device
Output: no reply

I must tell you that within my /boot/config.txt file, both i2cand spi are enabled
dtparam=spi=on
dtparam=i2c_arm=on

can both be working simultaneosly?

Thats all I tried to do to up to this point.

I hope you understand the above and will be glad to do any other experiments
you put forth. Please ask questions. I believe the pifacertctest will eventually be successful.

However, at this point, I dont know how the integration of the github.com/piface/PiFace-Real-Time-Clock install can be invoked along with pifacertctest install since the naming between the two is different and the two code listings are inherently incompatible (maybe a poor word choice). I wondered if you had an overall solution (vision) in mind.

Sorry for the bother and If you do not have time to continue, please tell me.
Thanks continually, Frank.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Nov 9, 2016 6:02 AM (in response to Frank Caracciolo)

Im assuming that solving the i2c bus problem has not solved the situation of the clock working. Its going to be difficult to help troubleshoot further without actually have one of the rtc clock modules myself but here are some steps that I would take, im going to make a numbered list of things for you to try, could you reply with a corresponding numbered list accordingly please

I know that the install script I modified works as intended and creates the "driver script" on the raspberry pi, this much I have been able to confirm simply by running the script myself, so from this point please try:

  1. Power off your raspberry pi and disconnect the piface rtc module, check to make sure that the battery on the module has power left in it and after a few minutes connect everything back up, once the raspberry pi boots back up type sudo hwclock -r please can you let us know the outcome of this. If its working, it should print a date/time to the terminal and if not it will display a problem communicating with the device

  2. install i2c tools sudo apt-get install i2c-tools and then run sudo i2cdetect -y 0 and then run sudo i2cdetect -y 1 One of these will return an error, the other one, most likely the latter will print out everything thats present on the i2c bus, it would handy if you could cut and paste or even do a screen shot of the output for us.

What Im trying to do is establish whether your raspberry pi is capable of communicating with or seeing if the rtc clock module is identifiable by your raspberry pi, this will help work out if the error is on the rtc clock module itself or whether its on the raspberry pi. As I say its difficult to troubleshoot something that I dont have physical contact with so if you could follow these instructions it would help greatly to move forwards with it.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 9, 2016 9:54 AM (in response to lucie tozer)

Dear ms. tozer,

your messages were very clear. Ran all you asked and (in my own naïve opinion) quite negative results.

1,) Powered off RPi0. Disconnected Ethernet module (enc28j60) and connections. I have WiPi operational on hub attached to RPi0. Disconnected battery. Removed RTC module. Removed Battery and verified output at 3.27 - 3.29 V. Returned Battery and RTC module. Installed battery (plus side up) and affixed pins to holes snuglt and securely. Rebooted. At terminal, typed: sudo hwclock -r (No date/time returned.) Return: hwclock: cannot access the hardware clock via any known method. hwclock: Use the debug option to see details of our search for any access method. My try: Typed: sudo hwclock --debug Return: hwclock from util-linux 2.25.2 hwclock: cannot open /dev/rtc : no such file or directory. No useful clock interface found hwclock: cannot access the hardware clock via any known method. My 2nd Try: (searched file manager). There is no file or directory at under: /dev named rtc.

2,) Typed: sudo apt-get install i2c-tools Return: Reading packing lists ..Done Building dependency tree Reading state information . . Done i2c is already the newest version 0 upgraded 0 newly installed 0 to remove 0 upgraded Typed: sudo i2cdetect -y 0 Return: Error: could not open file '/dev/i2c-0 or 'dev/i2c/0' No such file or directory Typed: sudo i2cdetect -y 1 Return: A matrix with 0 through 9 a b c d e f (across) 00: through 70 9down) " 6f " at 60: f all others -- .

As requested in your next post- Typed: cat /sys/bus/i2c/devices/1-006f/name Return: no such file or directory.

In my pi directory, I still have the two files:

install-piface-real-time-clock.sh

pifacertctest.sh

I'm my humble opinion I don't know how to manage the GitHub PiFace-Real-Time-Clock and pifacertctest .sh operations.

Your comments, thanks. Frank

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Roger Wolff
Level 5: Faraday

Roger Wolff Nov 9, 2016 10:08 AM (in response to Frank Caracciolo)

Hi Frank,

The good news is, your 'pi is communicating with the RTC. The i2c-detect tool asked: "Is there anybody at 0x6F?" and the chip answered: "Yes, I'm here, go ahead what do you want?" (the i2c-detect tool then turns around and does nothing. Quite mean towards the I2C chip that was willing to help... :-) ).

You can follow my instructions at: Rtc - BitWizard WIKI

You've gotten the I2C bus up-and-running, so some stuff is no longer necessary. Start with:

modprobe i2c:mcp7941x

echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device # For rev2 RPi

It seems that whomever made YOUR rtc was trying to do too much at once, possibly with some changes in raspbian that the automatic script wasn't prepared for....

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 9, 2016 1:56 PM (in response to Roger Wolff)

Dear Mr Wolff,

Just got your message but I'm at a library. Trying to follow Ms Tozers instructions but I appreciate the great insight you have concerning RTC. I see you have a follow up reply which I will respond to after I get these instructions in line. I have got a couple questions 1. what does bcm2708 and mcp7941x refer to specifically and do these pertain to a RPi Zero (is it the same for a RPi Zero version 2). You mentioned rev 2 RPi and rev 1 RPi, are these pertaining to a RPi Model 2 rev 1 and 2 or RPi zero version 1 and 2 or does it matter? My present concern is with an RPi Zero ver 1 but I will install an RPi Zero ver 2 in the future after resolving problems. I also have an RPi 3 which I want to install an RTC. Sorry for the questions but I'm getting more involved with these devices. Finally, the Rtc - BitWizard WIKI, is that a forum specifically tor RTC's ? Finally the end of this forum states the Source: http://www.element14.com/community/message/63885. This is very difficult to understand (I don't think I need to know it ) but is this forum separate then the one I'm on ?

Your support is well taken.

Thanks, Frank

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

lucie tozer
Level 6: Lovelace

lucie tozer Nov 9, 2016 6:13 AM (in response to Frank Caracciolo)

also, you got this part wrong in what you just posted

in your screenshot on one of your replies

Input: /sys/class/i2c-dev/i2c-1/device/new-device
Output: no reply

In the screen grab I effectively did(in a slightly different way):

cat /sys/bus/i2c/devices/1-006f/name

which should furnish you with a result once you have run the install script, the 1-006f part is the i2c address that the rtc clock module should be registered at, the name tells us the name of the module which is mcp7941x which is the microchip identifier on the rtc module.

Right now, Im more concerned with whether the rtc module is being identified rather than trying to debug the "driver" software, there could be many reasons for this so hopefully we can persevere!

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 9, 2016 10:12 AM (in response to lucie tozer)

Ms Tozer

Considering the results under your (above post) direction, the RTC is not identified. I have about a dozen RTC modules. I wish I can teleport one to you. I must say that I have installed the identical RTC 's on three individual RTC 2 devices running Wheezy using the original Raspberry Pi tutorial (sift through the above posts) which is nothing like the procedure I have been using on these RPi 0 's. As usual please tell me if you still have time to look at this. Also, as a sideline, I have no idea of this forum (and maybe I should start another post in General Discussion) but Are respondents generally from a worldwide environment? I realize you cannot answer for everyone. You certainly don't have to answer ( I am just curious) in particular, as I gathered from you website, are you a UK robotics person, just responding to me, or are you a member of element14 - farnell - Newark and now I think MCMelectronics. Your continued support is highly appreciated. Frank.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Peter Oakes
Level 8: Tesla

Peter Oakes Nov 9, 2016 10:29 AM (in response to Frank Caracciolo)

We're all here helping for free, some are Top Members, others are regular members, but we all love to help out, the odd response may be from a Newark/E14 staff member but 99% are just regular community members like violet

Me, I live in Canada but the help comes from all over the world

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Roger Wolff
Level 5: Faraday

Roger Wolff Nov 9, 2016 10:43 AM (in response to Peter Oakes)

I installed an MCP79410 on my raspberry. I then did the i2cdetect that was suggested. I get:

tenansix:/home/wolff# /usr/sbin/i2cdetect -y 1

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00: -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- 4a -- -- -- -- --

50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 6f

70: -- -- -- -- -- -- -- --

tenansix:/home/wolff#

"tenansix" is the name of this raspberry pi. The "4A" is another I2C device that lives on the I2C Bus.

The 6F is the "battery backed up RAM" part of the MCP-chip. The 57 is the actual RTC.

If you got "??" there (in the row "50" under the heading "7"), that means that your kernel driver has already claimed that device.

(I'm removing the board-with-RTC now, I have to be working on a different pi-addon-board).

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 9, 2016 2:04 PM (in response to Roger Wolff)

Again so many thanks , my immediate reaction is that I don't have a header describing my RTC (first line). Also, based on what you said, "my kernel driver has already claimed that device." At this point I don't know which kernel (is it the Linux kernel being used by the distrubution I am running ? and who claimed this device "myself" ?

Great ! What do you expect the matrix will look like if I get the RTC installed properly, a first line descriptor and another two-digit code somewhere in the matrix ?

Many thanks. This gives me confidence that I'm getting closer to installing these devices. I'll get to it in the very near future.

Frank.

Correct Answer'

Helpful Yes | No
Like
Show 0 Likes
(0)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Roger Wolff
Level 5: Faraday

Roger Wolff Nov 10, 2016 6:06 AM (in response to Frank Caracciolo)

The "rev 1" and "rev 2" versions refer to raspberry pi 1!!!

The processor on the raspberri pi's (all of them) is: BCM2835 (raspberry pi 1, zero), BCM2836 (Raspberry pi 2, before V1.2) or BCM2837 (raspberry pi 2 from V1.2 and rasbperry pi 3).

The BCM2835, back when it was new was treated as a BCM2708, which, from a software viewpoint was nearly identical. So the I2C module for BCM2835 was called i2c_bcm2708 or something like that.

MCP7941x is the name of our RTC chips.

My WIKI documents mostly MY boards (the boards BitWIzard sells). But in this case it also applies to you where you didn't buy our product but from the competition. Boo!!! :-)

You published a "something at 0x6F" scan. That means that your PI is talking to your RTC.

Next step is to insert the kernel modules that can talk to your RTC. I'm thinking this has already happend because you didn't see anything at 0x57. On the other hand, I THINK it should say "??" when you have the driver, and you didn't say anything about that. Please double check.

Then the "echo" command tells the driver: "There is a chip you can handle at address .... go ahead and look". For some hardware, just trying to fiddle with the chip and see if it reacts as you expect is "safe" If another chip happens to be there, nothing bad happens.

Consider the "I2C bus" like a street. You can walk up to "number 57", ring the bell and ask: "Are you an RTC?". However, at some addresses there are crazy people who don't like being asked any questions. They get out the shotgun if you don't behave exactly as they expect.

So... in some cases (e.g. on USB) it is perfectly fine to ask the "who are you" question. But on I2C it's sometimes dangerous because of those crazy guys. So in this case, on I2C, you need to tell the system: "it's ok to go and ask on nr 57 if they are an RTC!"

Correct Answer'

Helpful Yes | No
Like
Show 1 Likes
(1)
Reply
Actions
''

Re: Installing Code for PiFace Real Time Clock

Frank Caracciolo
Level 1: Coulomb

Frank Caracciolo Nov 10, 2016 3:39 PM (in response to Roger Wolff)

Again thanks for all this useful information.

I ran all you had asked me and I got some positive and negative results.

I ryped:

sudo nano /etc/modprobe.d/raspi-blacklist,conf and it was empty. I closed it and

Typed:

sudo modprobe i2c-bcm2708

Typed:

sudo -s

got into root prompt (I never went here before)

root@raspberrypi: /home/pi

typed the following three lines:

modprobe i2c-dev

modprobe i2c:mcp7941x

echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device

Return: Permission Denied

exited root

Typed:

hwclock -w

Typed: sudo hwclock -w

Return:

no such device

Typed: sudo hwclock -w (again)

Return:

no such device

Typed:

sudo hwclock --debug

Return:

cannot access the hardware clock by an known method

I have no /dev/rtc directory

I installed i2c-tools

Typed:

sudo i2cdetect -y 1

Return:

got the same matrix as before with no header information.

6f at ( 60: f ) but again all other locations gave - - (no ??)

I was >>successful<< in getting a mcp7941x return with:

cat /sys/class/i2c-dev/i2c-1/device/1-006f/name

or going to that directory and typing ls and then cat name

I never got a positive response before.

I guess that's all I did.

I hope I gave you some further information. It appears that the RTC is being identified but not completely.

The command

echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device

permission denied disturbed me

so I added a sudo in front of echo but it returned with something like "bad command".

I need to get the correct text allow permission.

Your consideration is of utmost value,

thanks, Frank.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants