Want to try a small electronics project without complicated circuits? In this beginner tutorial, we’ll build measure air pressure using esp32 and bmp280 sensor. You’ll connect one sensor, upload a short Arduino IDE sketch, and see the result. No Wi-Fi account or cloud service is required.

What does it do?
The BMP280 reads atmospheric pressure and temperature over I2C. Pressure can help you observe weather changes and estimate altitude, but it does not measure humidity.
Parts you’ll need
ESP32 board, BMP280 I2C breakout (3.3V-compatible), jumper wires, USB cable. You will also need a computer with the free Arduino IDE installed.
Wiring connections
Disconnect USB power before moving any wires. Make these connections carefully:
| Sensor / component pin | Connect to |
|---|---|
| BMP280 VCC/VIN | 3.3V |
| BMP280 GND | GND |
| BMP280 SDA | GPIO 21 |
| BMP280 SCL | GPIO 22 |
Important: ESP32 GPIO pins work at 3.3V. Do not connect a 5V output directly to an ESP32 input. Board and sensor-module pin labels vary, so double-check the markings on your hardware.
Arduino IDE code
Select the correct board and USB port in Arduino IDE, paste the complete sketch below, and click Upload.
#include <Wire.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if (!bmp.begin(0x76) && !bmp.begin(0x77)) {
Serial.println("BMP280 not found. Check wiring.");
while (true) delay(1000);
}
}
void loop() {
Serial.print("Pressure: ");
Serial.print(bmp.readPressure() / 100.0);
Serial.println(" hPa");
Serial.print("Temperature: ");
Serial.print(bmp.readTemperature());
Serial.println(" C");
delay(2000);
}
Expected result
Pressure: 1013.2 hPa, Temperature: 22.5 C Open Tools → Serial Monitor and set the baud rate shown in Serial.begin() in the sketch.
Troubleshooting
Install Adafruit BMP280 Library plus dependencies via Arduino IDE Library Manager. Most BMP280 I2C boards use address 0x76 or 0x77. Check your breakout’s 3.3V compatibility.
If nothing appears, first check the USB cable, correct board and port, sensor power and ground, and the Serial Monitor baud rate. Recheck every wire against the connection table before changing code.
What to try next
Once this simple example works, try changing the measurement interval or using the sensor reading to control an LED. This is an easy way to learn inputs, outputs, and basic programming.
For more hands-on electronics tutorials, explore CircuitMagic. If you later want to control Arduino or ESP32 projects from a phone over Bluetooth, see our BLE Controller app tutorial. This project itself does not need Bluetooth.










