import bme280 from smbus import SMBus import time port = 1 address = 0x76 # BME280 address bus = SMBus(port) bme280.load_calibration_params(bus,address) altitude = 97 def bme280Read(): bme280_data = bme280.sample(bus,address) humidity = bme280_data.humidity relPressure = bme280_data.pressure ambient_temperature = bme280_data.temperature absPressure = relPressure + (altitude/8.3) #print(humidity, pressure, ambient_temperature) # TODO calculate air pressure at sea level return bme280_data.humidity, bme280_data.pressure, bme280_data.temperature, absPressure # test loop """ while True: bme280Read() time.sleep(1) """