readme.md

Markdown · 63 lines

# ESP32 + DS18B20 — Captive Portal Live Temperature

![ESP32 Setup](https://i.imgur.com/4lk5nDC.png "ESP32 Setup")
![Web Portal](https://i.imgur.com/9KZ5zy1.png "Web Portal")

This project turns an **ESP32** into a **Wi-Fi captive portal** that displays **live temperature readings** from a **DS18B20** sensor.  
After connecting to the ESP32’s Wi-Fi network, any URL redirects to the portal page, where you can see the current temperature and adjust a few settings.

## Features
- Captive portal (AP + DNS redirect)
- Live DS18B20 temperature readout (auto-refresh)
- Simple settings in the portal (label + refresh interval)
- Works **without an external Wi-Fi network** (ESP32 runs as an Access Point)

## Hardware
- ESP32 development board
- DS18B20 temperature sensor (TO-92 or waterproof probe)
- **4.7 kΩ resistor** (pull-up for 1-Wire)

## Wiring (MOST IMPORTANT)

### DS18B20 (TO-92 package)
With the **flat side facing you**:
- **Left pin**  → GND
- **Middle pin** → DATA
- **Right pin** → 3V3

### Connections to ESP32 (default sketch pins)
- **DS18B20 VDD** → **3V3**
- **DS18B20 GND** → **GND**
- **DS18B20 DATA** → **GPIO4**
- **4.7 kΩ resistor** between **DATA** and **3V3**

### Waterproof probe (typical colors)
- **Red** → 3V3  
- **Black** → GND  
- **Yellow/White** → DATA (GPIO4)  
And the same **4.7 kΩ pull-up** between DATA and 3V3.

## Software
### Libraries (Arduino Library Manager)
- **OneWire** (Paul Stoffregen)
- **DallasTemperature** (Miles Burton)

ESP32 core already provides: `WiFi`, `WebServer`, `DNSServer`.

## How to use
1. Flash the sketch to the ESP32.
2. Connect your phone/PC to the Wi-Fi network: **esp32-ds18b20**
3. Open any website (or go directly to **http://192.168.4.1**)
4. You’ll see the live temperature and settings page.

## Customization
- Change DS18B20 DATA pin in code:
  - `static const uint8_t ONE_WIRE_PIN = 4;`
- Adjust refresh interval limits in the web form.
- Extend to multiple sensors by reading additional addresses via DallasTemperature.

## Notes / Troubleshooting
- If you see “no sensor detected”:
  - confirm DATA pin matches the code,
  - confirm the **4.7 kΩ pull-up** is installed,
  - verify you power the sensor from **3V3** and share **common GND**.