piface / PiFace-Real-Time-Clock

Installation script for PiFace Real Time Clock.
MIT License
13 stars 13 forks source link

Not working with Raspberry Pi 2 #1

Closed benoitguigal closed 9 years ago

benoitguigal commented 9 years ago

I can't get this script to work on a Raspberry Pi 2. Any idea ? Thanks a lot

tompreston commented 9 years ago

What happens when you run it? Does it error?

benoitguigal commented 9 years ago

Hello sorry for late reply. When the Raspberry Pi boots I get the following error

/etc/rc.local: 23 /etc/rc.local: cannot create /sys/class/i2c-dev/i2c-1/device/new_device: Directory nonexistent

Problem also mentioned here https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=109956&p=755348

tompreston commented 9 years ago

What do you get from the output of:

ls -l /sys/class/i2c-dev/

The install script adds the following lines to /etc/rc.local. The problem line is the third one below:

modprobe i2c-dev
modprobe i2c:mcp7941x
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-$i/device/new_device
hwclock -s

Where $i is either 1 or 0 depending on which Raspberry Pi you have.

benoitguigal commented 9 years ago

Actually I forgot to enable i2c in raspi-config prior to running the script. Maybe the error was due to that ?

tompreston commented 9 years ago

Since you hadn't enabled i2c in raspi-config then the device wouldn't appear which would explain the error. Are you still having problems? Does the RTC work even though you're getting the error?

benoitguigal commented 9 years ago

I managed to have it worked after enabling i2c, thanks

nemequ commented 9 years ago

It would be nice if the script would output better error message. A simple

if [ ! -e /sys/class/i2c-dev/i2c-$i ]; then
  echo "Error: you must enable i2c (use \`raspi-config\`, the \"Advanced Options\" section)."
fi

should (untested) do the trick…

Also, AFAICT there is no mention of i2c in the documentation until the troubleshooting section, it would be nice if the documentation mentioned this.