Unable to import explorerhat


#1

Hello everyone!

I’m playing around with a rpi 2 and an explorerhatpro, but sofar without much success.

I’m getting these errors when importing explorerhat:

import explorerhat
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python2.7/dist-packages/explorerhat.py”, line 624, in
_cap1208 = captouch.Cap1208()
File “/usr/local/lib/python2.7/dist-packages/captouch.py”, line 187, in init
self.i2c = SMBus(i2c_bus)
IOError: [Errno 2] No such file or directory

My guess is that ic2 is not enabled properly, however after struggling for 2 days my options are narrowing down…

i’ve followed the instruction to enable i2c and spi via sudo raspi-config in the resulting menu but without success

i’m running the latest raspbian wheezy image for rpi2

Any input is welcome.

Thank you in advance,

Alex


#2

Hi

Have you done
curl get.pimoroni.com/i2c | bash
(I wonder if that needs sudo?)
And
sudo apt-get install python-smbus

?


#3

I think raspi-config is actually missing some secret sauce, or perhaps not enabling the i2c-dev library properly. The first command @Gisky mentioned should fix it.

It may be that all you actually need from that script is:

sudo modprobe i2c-dev

… which loads the magical i2c modules which makes /dev/i2c-1 available.

But if you do it manually I think you have to do it upon every boot… boo!


#4

Thank you for your replies.

I forgot to mention that i had followed toroughly the github instructions. I’ve tried all forums posts from the last month or so (last rpi2 and last firmware) but without success. I’ve tried disabling the device tree and adding the modules manually in config.txt, made sure nothing was blacklisted…

i’ve started from a clean install again yesterday

when i run pimorini i2c’s script, it tells me that i2c is already enabled.

smbus is also already installed.

sudo modprobe i2c-dev returns no error message but i’m still unable to import explorer hat afterwards.

i2cdetect returns this message.

pi@raspberrypi ~ $ i2cdetect 1
Error: Could not open file /dev/i2c-1' or/dev/i2c/1’: No such file or directory

Could it be a faulty hat? leds 1 and 4 are on though…


#5

That’s weird…, a faulty HAT would not affect the presence of /dev/i2c-*, those should show up even if a HAT isn’t plugged in.

It doesn’t sound like you’ve missed a step!

Try this and see what appears:

ls /dev/i2c*

Also, have you run “rpi-update” at all? ( don’t run it! ) That might be useful to know.


#6

it returned

pi@raspberrypi ~ $ ls /dev/i2c*
ls: cannot access /dev/i2c*: No such file or directory

i did run ‘rpi-update’ on my previous installation but i started from scratch yesterday, haven’t run it since…


#7

latest oficial raspbian version has kernel 3.18 by default i guess, this is where the new device tree is introduced and problems start appearing…


#8

Device tree i2c definitely works, I’ve been using it for weeks and am now on kernel 3.18.7.

It might be worth disabling it altogether and seeing if that helps. Using:

device-tree=

In /boot/config.txt

It must be a configuration error somewhere though, but raspi-config is supposed to prevent that.

My config.txt includes the pertinent line:

dtparam=i2c_arm=on

And /etc/modules includes:

i2c-dev
i2c-bcm2708

When I run “lsmod” it shows:

Module       Size   Used by
i2c_dev      6027   0
i2c_bcm2708  4990   0

And when I “ls /dev/i2c*” it shows:

/dev/i2c-1

#9

It think it’s because i’m using berryboot to store the os on a usb drive.
I’m gonna try tonight from a traditional micro sd card…