Brookesa05
Posts: 22
Joined: Mon Apr 15, 2013 7:53 pm

Problem with IC2

Mon Apr 15, 2013 8:06 pm

Hello, i have connected and installed my new Adafruit-PWM/Servo driver board. I have got to the final part and when i run their Servo_Example.py code i get this error message.

File "/home/pi/....../...../Adafruit_PWM_Servo_Driver.py", line 31, in __init__
self.i2c = Adafruit_I2C(address, bus=smbus.SMBus(1))
TypeError:__init__() got an unexpected keyword argument 'bus'

i have followed the Adafruit instructions and Googled my problem and have to found any reason for this error.

Thanks in advance for any help....
Aidan Brookes

carbe
Posts: 1
Joined: Fri Apr 19, 2013 12:45 pm

Re: Problem with IC2

Fri Apr 19, 2013 12:55 pm

hey,
i got exactly the same problem today, any ideas yet?

User avatar
joan
Posts: 14887
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Problem with IC2

Fri Apr 19, 2013 3:15 pm

Guess.

The default I2C port changed from /dev/i2c-0 to /dev/i2c-1 at some stage (when the 512MB models were introduced?). Perhaps the Adafruit code hasn't been changed to reflect that change or you have an old style board?

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: Problem with IC2

Fri Apr 19, 2013 5:16 pm

you can use webiopi PCA9685 driver.
it's compatible with both rev1 and rev2 board.
moreover it's compatible with both python 2 and python 3, wheras adafruit / smbus is only compatible with python 2

https://code.google.com/p/webiopi/wiki/PCA9685

Code: Select all

from webiopi.devices.analog import PCA9685
pca = PCA9685()          # setup a PCA9685 I2C PWM
pca.pwmCount()              # returns PCA9685 pwm channel count
max = pca.pwmMaximum()      # returns PCA9685 maximum integer value
pca.pwmWrite(0, max)        # set 100% on PCA9685 pwm channel 0 (integer value)
pca.pwmWriteFloat(0, 0.5)   # set  50% on PCA9685 pwm channel 0 (float value)
pca.pwmWriteAngle(0, 0.0)   # set   0° on PCA9685 pwm channel 0 (servo angle value)
pca.pwmRead(0)              # returns PCA9685 pwm channel 0 as integer
pca.pwmReadFloat(0)         # returns PCA9685 pwm channel 0 as float
pca.pwmReadAngle(0)         # returns PCA9685 pwm channel 0 as angle

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

Return to “Interfacing (DSI, CSI, I2C, etc.)”