Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'int' object has no attribute 'write_byte' #10

Open
texasbobs opened this issue Jun 7, 2017 · 2 comments
Open

AttributeError: 'int' object has no attribute 'write_byte' #10

texasbobs opened this issue Jun 7, 2017 · 2 comments

Comments

@texasbobs
Copy link

When I run sht21.py alone, it completes and prints the proper values. When I run it with the sample in the readme, I get the attribute error. Being quite the noob, I'm not sure exactly how to fix that. Any guidance would be appreciated.

Traceback (most recent call last):
File "wx-02.py", line 2, in
with sht21.SHT21(1) as sht21:
File "/home/pi/wx/sht21.py", line 20, in init
self.bus.write_byte(self._I2C_ADDRESS, self._SOFTRESET)
AttributeError: 'int' object has no attribute 'write_byte'

@texasbobs
Copy link
Author

Actually I did edit the usage sample to point to bus 1.

This is what I'm running that generates the error.

import sht21
with sht21.SHT21(1) as sht21:
print "Temperature: %s"%sht21.read_temperature()
print "Humidity: %s"%sht21.read_humidity()

@texasbobs
Copy link
Author

After playing around, It was able to get the following to work. Is the usage sample wrong or am I doing something else wrong?

import sht21
import smbus

bus = smbus.SMBus(1)
with sht21.SHT21(bus) as sht21:
print "Temperature: %s"%sht21.read_temperature()
print "Humidity: %s"%sht21.read_humidity()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant