# Rui Santos & Sara Santos - Random Nerd Tutorials # Complete project details: https://RandomNerdTutorials.com/raspberry-pi-pico-bme680-micropython/ from machine import Pin, I2C from time import sleep from bme680 import * # RPi Pico - Pin assignment i2c = I2C(id=0, scl=Pin(5), sda=Pin(4)) bme = BME680_I2C(i2c=i2c) while True: try: temp = str(round(bme.temperature, 2)) + ' C' #temp = (bme.temperature) * (9/5) + 32 #temp = str(round(temp, 2)) + 'F' hum = str(round(bme.humidity, 2)) + ' %' pres = str(round(bme.pressure, 2)) + ' hPa' gas = str(round(bme.gas/1000, 2)) + ' KOhms' print('Temperature:', temp) print('Humidity:', hum) print('Pressure:', pres) print('Gas:', gas) print('-------') except OSError as e: print('Failed to read sensor.') sleep(5)