The BME280 is a natural add-on for the Nano ESP32: temperature, humidity and pressure, ready to publish over Wi-Fi. Wire it to 3V3, GND, A4 (SDA) and A5 (SCL).
The sketch prints the chip ID and then a reading every 2 s.
Wiring
| Arduino Nano ESP32 | BME280 breakout | Wire | Notes |
|---|---|---|---|
| 3V3 | VIN / VCC | red | |
| GND | GND | black | |
| A4 | SDA | blue | |
| A5 | SCL | yellow |
3.3 V (VIN boards with a regulator: 3.3–5 V) part, 3.3 V board. The chip itself is 3.3 V-only. Many purple 6-pin boards have no regulator — feed them 3.3 V only. Boards with a VIN pin and regulator accept 5 V, but keep SDA/SCL at the board's logic level.
Board quirks
- A4/A5 are the Nano ESP32’s I2C pins, same as a classic Nano. Inside they are GPIO11/12 of the ESP32-S3.
- Power from 3V3. The common purple BME280 board has no regulator or level shifting; it must not see 5 V.
- Because A4–A7 are ADC2 pins, the Nano ESP32 loses analog on them with Wi-Fi on. Using them for I2C leaves A0–A3 (ADC1) free for analog sensors.
Code
// BME280 on an Arduino Nano ESP32 over I2C.
// VIN → 3V3, GND → GND, SDA → A4, SCL → A5.
#include <Wire.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
void setup() {
Serial.begin(115200);
uint32_t t0 = millis();
while (!Serial && millis() - t0 < 3000) {}
Wire.begin(); // A4 / A5
if (!bme.begin(0x76, &Wire) && !bme.begin(0x77, &Wire)) {
Serial.println("No BME280 at 0x76 or 0x77 - check SDA/SCL and power");
while (true) delay(1000);
}
Serial.printf("Sensor ID 0x%02lX\n", (unsigned long)bme.sensorID());
}
void loop() {
Serial.printf("Temp %.1f C Humidity %.1f %% Pressure %.1f hPa\n",
bme.readTemperature(), bme.readHumidity(), bme.readPressure() / 100.0F);
delay(2000);
}// BME280 on an Arduino Nano ESP32 over I2C.
// VIN → 3V3, GND → GND, SDA → A4, SCL → A5.
#include <Wire.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
void setup() {
Serial.begin(115200);
uint32_t t0 = millis();
while (!Serial && millis() - t0 < 3000) {}
Wire.begin(); // A4 / A5
if (!bme.begin(0x76, &Wire) && !bme.begin(0x77, &Wire)) {
Serial.println("No BME280 at 0x76 or 0x77 - check SDA/SCL and power");
while (true) delay(1000);
}
Serial.printf("Sensor ID 0x%02lX\n", (unsigned long)bme.sensorID());
}
void loop() {
Serial.printf("Temp %.1f C Humidity %.1f %% Pressure %.1f hPa\n",
bme.readTemperature(), bme.readHumidity(), bme.readPressure() / 100.0F);
delay(2000);
}Library: Adafruit BME280 Library (Adafruit (also install Adafruit Unified Sensor)) — compiled with Adafruit BME280 Library 2.3.0.
Expected serial output
Sensor ID 0x60
Temp 28.6 C Humidity 60.8 % Pressure 1006.0 hPa
Temp 28.6 C Humidity 60.7 % Pressure 1006.0 hPaSensor ID 0x60 Temp 28.6 C Humidity 60.8 % Pressure 1006.0 hPa Temp 28.6 C Humidity 60.7 % Pressure 1006.0 hPa
Common errors
“No BME280 at 0x76 or 0x77”
Check A4/A5 and 3V3. Full fix.
Sensor ID 0x58
BMP280 — no humidity.