Open texasbobs opened 7 years ago
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()
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()
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'