Hi! I’ve had Python programs running pulling data from my WeatherHAT very nicely for a few weeks now.
I’ve just added an external BME280 connected to the i2c extension on the board. Ever since then I am getting an error when running the (previously working) programs:
Traceback (most recent call last):
File “/home/pi/weatherhat-python/examples/adafruit-io_MPH.py”, line 2, in
import weatherhat
File “/usr/local/lib/python3.9/dist-packages/weatherhat/init.py”, line 7, in
from bme280 import BME280
ImportError: cannot import name ‘BME280’ from ‘bme280’ (/home/pi/weatherhat-python/examples/bme280.py)
I’ve done some Googling, and tried downgrading the bme280 library using:
sudo pip install pimoroni-bme280==0.0.2
This hasn’t made any difference. I’m pretty stuck at the moment, can anyone help a Python newbie?
You have to cut the address select jumper on the back of the bme280, you added to i2c. You can’t have two devices with the same i2c address. You will also have to adjust your code to use two bme280’s.
EDIT: For me I just run the stock BME280 installer. They will both use the one library. sudo pip install pimoroni-bme280 smbus
For you the weather hat installer should be enough to run both BME280’s
That’s great! Thanks so much. I’m trying to figure out how to change the address on the particular version I have. In the meantime, my original problem still happens with the “other” BME280 completely disconnected, which is very strange. I think I’m going to try a clean install on the pi to see if that gets me back to where I was.
Well, I cloned the install from github again, and now it works so I’m starting from a good place again. Thanks for the steer on i2c addressing, that’s next on the list.
It works! Yay! I found that some cheap BME280s I bought on line just would not change address, it
wasn’t possible to sever the link between the first two solder pads. I ponied up for a better one, and
that works a treat. I think the documentation on the Weather Hat could be better, I was initially trying to make sense of, and connect to, the obvious connection on the front of the board. It was only later that I found the actual i2c connector on the side of the board. Anyway, got there in the end, so thanks for your help.
Glad you got it working! I’ve tidied up the bit of the shop page description that refers to where the ADC and I2C headers are located on Weather HAT to try and make it a bit clearer which is which.