I²C sensor: temperature, humidity, pressure
Environmental sensors like the BME280 sit on the I²C bus at a fixed address and return calibrated readings. A library hides the register details; the program’s job is to read on a schedule and act, here lighting the LED when it is hotter than 30 °C.

Open this lesson in the labFree, in your browser, no account needed.
How it works
BME280 at 0x76 (0x77 with SDO high). Temperature ±1 °C, humidity ±3 %RH, pressure ±1 hPa. Pressure falls about 12 hPa per 100 m of altitude, so it doubles as an altimeter.
The sensor heats itself a little when read quickly: one reading per second is plenty for room conditions.
Try it on the bench
- Select the sensor and raise the temperature past 30 °C: the onboard LED comes on.
- Change the address in the sketch to 0x77: “BME280 not found”.
Parts on the bench
- Bench power supply
- ESP32 DevKit
- USB charger / port
- BME280 environment sensor
In the course
Zen’s Electronics Design Mastery, module “Microcontrollers & Embedded”.