readme.md

Markdown · 51 lines

# ESP32 BME280 Captive Portal (FlashESP)

|  |  |
|:-:|:-:|
| ![Example usage](https://i.imgur.com/zcms95i.jpeg) | ![Example usage](https://i.imgur.com/nKWZ1j3.jpeg) |

## Short description
ESP32 creates an **open Wi-Fi Access Point (no password)** with a **captive portal**.  
When you connect, the portal page displays live readings from a **BME280 (3.3V)** sensor: **temperature, humidity, and pressure** (auto-refresh every 2 seconds).

---

## Wiring (ESP32 ↔ BME280, I2C, 3.3V)
> Default I2C pins on ESP32 DevKit boards: **GPIO21 = SDA**, **GPIO22 = SCL**

| BME280 pin | ESP32 pin | Notes |
|---|---:|---|
| **VCC / VIN** | **3.3V** | Sensor power (3.3V only) |
| **GND** | **GND** | Ground |
| **SDA** | **GPIO21** | I2C data |
| **SCL** | **GPIO22** | I2C clock |

### Notes
- Many BME280 boards use I2C address **0x76** or **0x77**. The example code tries both.
- If your module has **SDO / ADDR** pin, it often selects the I2C address (0x76 vs 0x77).
- Keep wires short for stable I2C (especially on breadboards).
- On **ESP32-C3 / C6 / S2 / S3** boards GPIO21/22 may not exist or be mapped differently — use the pins marked SDA/SCL on your board and change `Wire.begin(SDA, SCL)` accordingly (e.g. `Wire.begin(8, 9)` on many ESP32-C3 boards).

---

## Required libraries
Install via Arduino Library Manager:
- **Adafruit BME280 Library**
- **Adafruit Unified Sensor**

ESP32 / Arduino core built-ins (no extra install):
- Wire
- WiFi
- WebServer
- DNSServer

---

## How to use
1. Flash the firmware to ESP32 using **FlashESP**.
2. Power the ESP32 and BME280 (3.3V).
3. Connect to Wi-Fi network: **ESP32_BME280** (open network).
4. Captive portal should open automatically. If not, open any website or go to `http://192.168.4.1`.
5. The portal page shows **Temperature / Humidity / Pressure** and refreshes automatically every 2 seconds.

---