- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi,
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 (https://learn.sparkfun.com/tutorials/htu21d-humidity-sensor-hookup-guide/htu21d-library-and-function... https://learn.sparkfun.com/tutorials/htu21d-humidity-sensor-hookup-guide/htu21d-library-and-function...) 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: https://richardstechnotes.wordpress.com/2014/11/05/using-i2cdetect-on-the-intel-edison-and-getting-i... https://richardstechnotes.wordpress.com/2014/11/05/using-i2cdetect-on-the-intel-edison-and-getting-i.... 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 SMBus_direct_HTU21D.py
Traceback (most recent call last):
File "SMBus_direct_HTU21D.py", line 8, in
val = bus.read_i2c_block_data(0x40, 0xE3, 3)
File "/usr/lib/python2.7/site-packages/smbus/util.py", line 59, in validator
return fn(*args, **kwdefaults)
File "/usr/lib/python2.7/site-packages/smbus/smbus.py", line 258, in read_i2c_block_data
raise IOError(ffi.errno)
IOError: 110
Smbus poke script success after running the wirehack:
root@Edison1:~# python SMBus_direct_HTU21D.py
[106, 144, 130]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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: https://github.com/intel-iot-devkit/mraa intel-iot-devkit/mraa · GitHub
Regards,
Diego.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page