Closed sumghai closed 5 years ago
@sumghai Bug confirmed. Tested on my Raspberry Pi 3 Model B.
There is no documentation/comment anywhere related to the new i2c
parameter introduced in the latest commit #6, like what should be its value? @kattni can you please help?
@sumghai @abhiTronix We were fixing a different I2C bug and introduced this one. This is fixed by https://github.com/adafruit/Adafruit_Blinka/pull/95. Please update Adafruit_Blinka to resolve the issue. I've done a new release - give it a few minutes to deploy to PyPI before trying to update.
To answer your question, @abhiTronix, to pass in different pins, you would instantiate the library as follows:
import busio
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16, i2c=(busio.I2C(board.SCL, board.SDA)))
I have only tested that on a microcontroller, not on RasPi, but that is the idea of how to pass in different I2C pins.
I can confirm that updating Adafruit Blinka to 1.2.7 resolves this issue on the RasPi.
Thanks @kattni!
HI,
I am trying to use below code on python3 and have same error
import busio
import adafruit_tsl2561
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_tsl2561.TSL2561(i2c)
I am using Rpi 3B+ with Adafruit-Blinka 3.3.4
Name: Adafruit-Blinka
Version: 3.3.4
Summary: CircuitPython APIs for non-CircuitPython versions of Python such as CPython on Linux and MicroPython.
Home-page: https://github.com/adafruit/Adafruit_Blinka
Author: Adafruit Industries
Author-email: circuitpython@adafruit.com
License: MIT
Location: /usr/local/lib/python3.5/dist-packages
Requires: Adafruit-PlatformDetect, rpi-ws281x, spidev, RPi.GPIO, sysv-ipc, pyftdi, Adafruit-PureIO
I got below error
File "./TSL2561c.py", line 12, in <module>
i2c = busio.I2C(board.SCL, board.SDA)
AttributeError: module 'board' has no attribute 'SCL'
You aren't importing board
? But somehow it must be or the error would be different. What does this show?
import board
dir(board)
You aren't importing
board
? But somehow it must be or the error would be different. What does this show?import board dir(board)
Sorry, I didn't double check the code I post, I have , it's at first line and I miss to copy it and paste here. but I am 100% sure import board is there, I add your line and it didn't show alarm but I found further when print out, it looks my board have some problem
import time
import board
dir(board)
import busio
import adafruit_tsl2561
print("board contents: ", dir(board))
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_tsl2561.TSL2561(i2c)
python3 TSL2561c.py
board contents: ['BaseDimension', 'Board', 'Dimension', 'Empty', 'Image', 'InfiniteDimension', 'Infinity', '_Empty', '_InfiniteDimension', '_Infinity', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_centred_coord', 'cornerposts', 'functools', 'imagefile_sprite', 'io', 'itertools', 'long', 'os', 'sys', 'text_sprite']
Traceback (most recent call last):
File "TSL2561c.py", line 15, in <module>
i2c = busio.I2C(board.SCL, board.SDA)
AttributeError: module 'board' has no attribute 'SCL'
I found other people should come out like this, what's wrong with my board
board contents: ['CE0', 'CE0_1', 'CE1', 'CE1_1', 'D10', 'D11', 'D12', 'D13', 'D16', 'D17', 'D18', 'D19', 'D20', 'D21', 'D22', 'D23', 'D24', 'D25', 'D26', 'D27', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'I2C', 'MISO', 'MISO_1', 'MOSI', 'MOSI_1', 'SCK', 'SCK_1', 'SCL', 'SCLK', 'SCLK_1', 'SCL_1', 'SDA', 'SDA_1', 'SPI', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'spec', 'ap_board', 'board_id', 'detector', 'pin', 'sys']
pip3 list
Adafruit-Blinka (3.3.4)
adafruit-circuitpython-busdevice (4.1.0)
adafruit-circuitpython-lis3dh (5.0.1)
adafruit-circuitpython-tsl2561 (3.2.2)
Adafruit-PlatformDetect (1.3.8)
Adafruit-PureIO (1.0.4)
board (1.0)
looks like you have some other library that has created a board.py in your python collection, & you'll have to remove it
Yep. You somehow have this installed:
https://pypi.org/project/board/
instead of the board
that comes with Blinka.
You can not install the board
module individually. You need to do a complete Blinka install.
Thanks @caternuson and @ladyada after remove board and reinstall Blinka, work as expect.
@hamwong solved?
Summary of Issue
Attempting to initialize the class object from
ServoKit
results in the following error:Hardware
Software and Environment
servo_test.py
Notes
i2c = busio.I2C(board.SCL, board.SDA)
instead of the currenti2c = board.I2C()
; perhaps this line may be of interesti2c = busio.I2C(board.SCL, board.SDA)