MicroPython sensor reading — DHT11/22, BME280, MPU6050, ADC, ultrasonic HC-SR04, photoresistor, generic I2C sensors.
Code templates for reading common sensors on MicroPython devices. All sensor reads are Safe tier — execute directly without user confirmation.
Always adapt pin numbers to the target board. When unsure, ask the user which GPIO pins are connected.
import dht, json
from machine import Pin