Community
cancel
Showing results for 
Search instead for 
Did you mean: 
nDE_S
New Contributor I
1,583 Views

problems to use python-smbus to control driver i2c of the Openelectrons

Hi guys,

Following this site: https://communities.intel.com/thread/61160 https://communities.intel.com/thread/61160

I do this:

pip install cffi

and then:

pip install smbus-cffi

 

After I tried install run python scrit to detect i2c address in my intel edison and I have error with python-smbus

root@edisonb:~/opt# python explorer1.py

Connect I2C device...

Traceback (most recent call last):

File "explorer1.py", line 31, in

i2c = explorerlib.Explorer(addr)

File "/home/root/opt/explorerlib.py", line 35, in __init__

OpenElectrons_i2c.__init__(self, explorer_address >> 1)

File "/home/root/opt/OpenElectrons_i2c.py", line 57, in __init__

self.bus = smbus.SMBus(b)

File "/usr/lib/python2.7/site-packages/smbus/smbus.py", line 56, in __init__

self.open(bus)

File "/usr/lib/python2.7/site-packages/smbus/smbus.py", line 83, in open

raise IOError(e.errno)

IOError: 2

Help me please

12 Replies
Sergio_A_Intel
Employee
154 Views

Hi,

When you ran the first two commands did you receive any errors? What image are you using? What are the contents of explorer1.py?

Sergio

nDE_S
New Contributor I
154 Views

Hi Sergio

root@edisonb:~/opt/i2c-tools# configure_edison --version

159

But I think the problem is not this.

explorer1.py

# !/usr/bin/env python

 

#

 

# Copyright (c) 2014 OpenElectrons.com

 

# Explorer example script.

 

#

 

# This program is free software; you can redistribute it and/or modify

 

# it under the terms of the GNU General Public License version 2 as

 

# published by the Free Software Foundation.

 

#

 

# This program is distributed in the hope that it will be useful,

 

# but WITHOUT ANY WARRANTY; without even the implied warranty of

 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

 

# GNU General Public License for more details.

 

#

 

# You should have received a copy of the GNU General Public License

 

# along with this program; if not, write to the Free Software

 

# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 

#

 

# History:

 

# Date Author Comments

 

# 04/15/14 Michael Initial authoring.

 

#

 

import time

import os, sys

import explorerlib

print "Connect I2C device..."

time.sleep(3)

addr = 0x00 # DO NOT change this address!!!

 

i2c = explorerlib.Explorer(addr)

found = i2c.ping(0x00)

# Checks for connection on all I2C addresses until connection is found

 

while found == -1:

if (addr < 0xef):

addr = addr + 1

i2c = explorerlib.Explorer(addr)

found = i2c.ping(0x00)

else:

addr = 0x00

print "--------------------"

print "7 bit address: " + str(hex(addr/2)) # RaspberryPi will find device at this address

 

print "8 bit address: " + str(hex(addr)) # Use this address for use with OpenElectrons_i2c.py

 

print i2c.GetFirmwareVersion()

print i2c.GetVendorName()

print i2c.GetDeviceId()

print "--------------------"

# Press Pause/Break button on your keyboard to stop the program

 

root@edisonb:~/opt/i2c-tools# i2cdetect -y -r 1

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

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

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

20: UU UU UU UU -- -- -- -- -- -- -- -- -- -- -- --

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

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

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

root@edisonb:~/opt/i2c-tools# i2cdetect -y -r 6

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

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

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

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

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

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

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

Other attempt is this: /thread/52982 https://communities.intel.com/thread/52982

everything was going well until:

root@edisonb:~/opt/i2c-tools# make install

install -m 755 -d /usr/local/include/i2c

make: install: Command not found

include/Module.mk:19: recipe for target 'install-include' failed-- -- -- -- -- --

make: *** [install-include] Error 127

nDE_S
New Contributor I
154 Views

My Smartdrive board (http://www.mindsensors.com/rpi/76-smartdrive-high-current-motor-controller?search_query=Smartdrive&r... SmartDrive High Current Motor Controller) still not detected in i2cDETECTS commands. Using m2ctool and i2cdetect. What I can do now

still not detected~

Sergio_A_Intel
Employee
154 Views

Hi,

How are you powering the smart drive motor controller and the Edison? From what link did you downloaded the code, this code is not going to work on the Edison without making some changes first. If you look at the comments on the print statements you'll notice this code and the motor controller were designed for a Raspberry Pi so the addresses that I2C will use to communicate will not be the same for the Edison.

Also, if you want to install i2c-tools why not try downloading and installing with opkg: opkg install i2c-tools

Sergio

nDE_S
New Contributor I
154 Views

I've done this and more: opkg install i2c-tools

Will I need this : /thread/52982 https://communities.intel.com/thread/52982 ?

What about this error in that site:

root@edisonb:~/opt/i2c-tools# make install

install -m 755 -d /usr/local/include/i2c

make: install: Command not found

include/Module.mk:19: recipe for target 'install-include' failed-- -- -- -- -- --

make: *** [install-include] Error 127

 

below pictures of i2c connections that tried. With and without GROVE KIT. I use A4/27 and A5/28 = i2c1 and A4/27 and A5/28 i2c6

 

nDE_S
New Contributor I
154 Views

Now I can. I2C 7 bit address of datasheet

nDE_S
New Contributor I
154 Views

I need now know commands to run motor 1/motor 2 in linux shell commands using i2c

Sergio_A_Intel
Employee
154 Views

Hi,

Were you able to run the make command without issues? You can also find several commands that work for this sensor in http://www.mindsensors.com/index.php?controller=attachment&id_attachment=121 http://www.mindsensors.com/index.php?controller=attachment&id_attachment=121

Sergio

nDE_S
New Contributor I
154 Views

Sergio,

I can't run make command. I need explorer1.py

Sergio_A_Intel
Employee
154 Views

Run the command opkg install make to install make and try again.

Sergio

nDE_S
New Contributor I
154 Views

Sergio,

root@edisonb:~/opt/i2c-tools# make EXTRA="py-smbus"

cd py-smbus && python setup.py build

running build

running build_ext

root@edisonb:~/opt/i2c-tools# opkg install make

Package make (4.0-r0) installed in root is up to date.

root@edisonb:~/opt/i2c-tools# make install

install -m 755 -d /usr/local/include/i2c

make: install: Command not found

include/Module.mk:19: recipe for target 'install-include' failed

make: *** [install-include] Error 127

root@edisonb:~# pwd

/home/root

root@edisonb:~# opkg install make

Package make (4.0-r0) installed in root is up to date

nDE_S
New Contributor I
154 Views

Solved

Thank's All right

Reply