Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9872 Discussions

Edison Mini breakout board I2C init problem using Python



On a Edison Mini Breakout board, I have hard-wired an HTU21D to the I2C6 pins (J17 pins 7 & 9). If I run a Sparkfun basic demo Arduino sketch ( it works just fine - produces temp and humidity readings without errors.

If I run an Adafruit HTU21D Python demo script on the same setup I get I2C errors 100% of the time. Then, if I run this "wirehack" Arduino sketch then the Python code starts working: To eliminate the Adafruit code layers, I poked directly at the smbus with this Python script, with the same results… doesn't work until the wirehack Arduino sketch is run. I've started to look at the Arduino wire.cpp.

It seems that something is missing in the initialization of the I2C port 6 in the Python code. Is this a well-known problem with a not-so-well-known Python init code fix for I2C usage?

Smbus poke script:

# !/usr/bin/python

from smbus import SMBus

bus = SMBus(6)

# read temperature register 3 bytes

val = bus.read_i2c_block_data(0x40, 0xE3, 3)

print val

Smbus poke scrip error before running wirehack:

root@Edison1:~# python

Traceback (most recent call last):

File "", line 8, in

val = bus.read_i2c_block_data(0x40, 0xE3, 3)

File "/usr/lib/python2.7/site-packages/smbus/", line 59, in validator

return fn(*args, **kwdefaults)

File "/usr/lib/python2.7/site-packages/smbus/", line 258, in read_i2c_block_data

raise IOError(ffi.errno)

IOError: 110

Smbus poke script success after running the wirehack:

root@Edison1:~# python

[106, 144, 130]

1 Reply

Hello cjnaz,

In order to use an Edison's interfaces (I2C, SPI, UART, etc), the muxes should be configured first. According to your description, the Python script is not configuring the muxes properly. If that Python script is generic (I mean, not written for Edison) then it isn't configuring the muxes and the I2C interface is not set up.

On the other hand, the Arduino sketch works because the I2C is configured through the Arduino IDE. For Python scripts I recommend you to use the MRAA library which was made to use the Edison's interfaces and the mux configuration is made transparently for the user, like the Arduino IDE does: intel-iot-devkit/mraa · GitHub