Comments on: Raspberry Pi Pico: DHT11/DHT22 Temperature and Humidity Sensor (MicroPython) https://randomnerdtutorials.com/raspberry-pi-pico-dht11-dht22-micropython/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Mon, 06 May 2024 10:55:12 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: JB https://randomnerdtutorials.com/raspberry-pi-pico-dht11-dht22-micropython/#comment-876383 Wed, 06 Dec 2023 20:08:29 +0000 https://randomnerdtutorials.com/?p=132919#comment-876383 Remember to install the ‘micropython-bme280’ package

]]>
By: JB https://randomnerdtutorials.com/raspberry-pi-pico-dht11-dht22-micropython/#comment-876381 Wed, 06 Dec 2023 20:03:49 +0000 https://randomnerdtutorials.com/?p=132919#comment-876381 Hi.
If someone would like to use the bme280 sensor.
Then this can be used with micropython and Thonny.

import machine
import bme280
from time import sleep

i2c = machine.I2C(id=0, scl=machine.Pin(1), sda=machine.Pin(0))
bme = bme280.BME280(i2c=i2c)

while True:
try:
sleep(2)
print(bme.values)
temperature = bme.values[0]
temperature = “{:.1f}”.format( float(temperature[:-1]))
humidity = bme.values[2]
humidity = “{:.1f}”.format( float(humidity[:-1]))
pressure = bme.values[1]
pressure = “{:.1f}”.format( float(pressure[:-3]))

#print(temperature + “C” )
print(temperature)
print(humidity)
print(pressure)
except OSError as e:
print(‘Failed to read sensor.’)

]]>