I'm trying to create a sensing station using the BME280 temperature, pressure, and humidity sensor and a raspberry pi. When I run my python code, I receive the error: "RuntimeError: Unable to find bme280 on 0x76, IOError" When I run i2cdetect -y 1, the address the device is on is 0x77. How do I fix this? I'm very new to electronics work, so any and all help is appreciated. My code is below.
import time
try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
from bme280 import BME280
print("""bmeTest.py - Read temperature, pressure, and humidity
Press Ctrl+C to exit!
""")
# Initialize the BME280
bus = SMBus(1)
bme280 = BME280(i2c_dev=bus)
while True:
temperature = bme280.get_temperature()
pressure = bme280.get_pressure()
humidity = bme280.get_humidity()
print('{:05.2f}*C {:05.2f}hPa {:05.2f}%'.format(temperature, pressure, humidity))
time.sleep(1)
There are two possible solutions to fix this problem.
i2c_addr
. The default value is I2C_ADDRESS_GND
but you can change it: bme280 = BME280(i2c_dev=bus, i2c_addr=I2C_ADDRESS_VCC)