bme280
bme280 copied to clipboard
Attribute Error
Hi
I use bme280 0.3 package. As "i2cdetect -y 1" command returns, my BME280 has address 0x77 and "read_bme280 -- help" command works well. But when I test "read_bme280 --i2c-address 0x77" command, following error appears:
Traceback (most recent call last):
File "/usr/local/bin/read_bme280", line 9, in
Can anybody help me?
There should of been a warning like
smbus is not available, you will not be able to use i2c
If so you need to follow the instructions in the README, mainly:
For I2C access you must have the 'smbus' package available - for debian based systems install python-smbus. If you wish to compile it, the package required is smbus-cffi (https://pypi.python.org/pypi/smbus-cffi/)
Thank you kbrownlees I am using Raspberry pi 3 board with Rasbian and I have smbus 1.1 running on it and as I checked, I have the newest i2c library versions on it too. But still having the problems. My python version is 3.4.2 and I have bme280 version 0.3 installed library too.
Also, when I run "pip install smbus-cffi", I recerive an error which it says " ... No distribution at all found for smbus-cffi ... "
Should I make more changes in Raspberry pi configuration?
I have two smbus-like libs installed, so not sure which one was needed...
pi@raspberrypi:~ $ pip3 search smbus
Adafruit-PureIO (0.2.1) - Pure python (i.e. no native extensions) access to Linux
IO including I2C and SPI. Drop in replacement for smbus
and spidev modules.
smbus-cffi (0.5.1) - This Python module allows SMBus access through the I2C
/dev interface on Linux hosts. The host kernel must have
I2C support, I2C device interface support, and a bus
adapter driver.
INSTALLED: 0.5.1 (latest)
pyblinkm (0.1.0) - Drive a BlinkM with Python via I2C using python-smbus on
Raspberry Pi.
pysmbus (0.1) - Pure Python implementation of the I2C SMBus protocol.
smbus2 (0.2.0) - smbus2 is a drop-in replacement for smbus-cffi/smbus-
python in pure Python
INSTALLED: 0.2.0 (latest)
And this seems to be the minimum Python needed to get a result...
pi@raspberrypi:~/$ python3
Python 3.5.3
Type "help", "copyright", "credits" or "license" for more information.
>>> from bme280 import bme280
>>> bme280.bme280_i2c.set_default_i2c_address(0x76)
>>> bme280.bme280_i2c.set_default_bus(1)
>>> bme280.setup()
>>> bme280.read_all()
Data(humidity=55.73471521799349, pressure=948.001722783354, temperature=11.319838337250985)
Hope this helps.