bme680_simpletest.py
1 import time 2 import board 3 from busio import I2C 4 import adafruit_bme680 5 6 # Create library object using our Bus I2C port 7 i2c = I2C(board.SCL, board.SDA) 8 bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c, debug=False) 9 10 # change this to match the location's pressure (hPa) at sea level 11 bme680.sea_level_pressure = 1013.25 12 13 # You will usually have to add an offset to account for the temperature of 14 # the sensor. This is usually around 5 degrees but varies by use. Use a 15 # separate temperature sensor to calibrate this one. 16 temperature_offset = -5 17 18 while True: 19 print("\nTemperature: %0.1f C" % bme680.temperature + temperature_offset) 20 print("Gas: %d ohm" % bme680.gas) 21 print("Humidity: %0.1f %%" % bme680.humidity) 22 print("Pressure: %0.3f hPa" % bme680.pressure) 23 print("Altitude = %0.2f meters" % bme680.altitude) 24 25 time.sleep(1)