readme.md
Markdown · 124 lines
# ESP32 nRF24L01+ Captive Portal Tester
### Test an nRF24L01+ PA/LNA 2.4 GHz radio module over WiFi with a captive portal
This project turns an **ESP32 Dev Board** into a diagnostic tool for the
**nRF24L01+ ISM 2.4 GHz module with power amplifier (PA/LNA) and external antenna**.
When powered, the ESP32 creates an **open WiFi Access Point** and a **captive portal**.
As soon as a device connects to the AP, a page appears showing whether the radio
module is correctly wired and working.
---
## ⭐ Features
- **Open WiFi Access Point** (no password)
- SSID: `ESP32-nRF24-Test`
- **Captive portal**
- Any URL request (e.g. `google.com`) is redirected to the test page
- Works with Android / iOS / Windows / Linux
- **Automatic module self-test** performed at boot and on demand
- `radio.begin()` – SPI initialization
- `isChipConnected()` – verifies the chip answers over SPI (catches wiring / power faults)
- `isPVariant()` – confirms it is a genuine nRF24L01**+** (250 kbps capable)
- **Channel** register write / read-back
- **Data-rate** (250 kbps) register write / read-back
- Reports current **data rate** and **PA power level**
- **Clear PASS / FAIL verdict** with a troubleshooting hint box
- **"Run test again"** button to re-test after fixing wiring
- No external network or internet required
---
## 📦 Hardware requirements
- **ESP32 Dev Board** (e.g. ESP32-DevKitC)
- **nRF24L01+ PA/LNA** module with external (SMA) antenna
- Recommended: a **10–100 µF** electrolytic capacitor across the module's **VCC–GND**
(or an nRF24 adapter/breakout board with a voltage regulator)
> ⚠️ **Power warning:** the PA/LNA version draws short high-current spikes when the
> amplifier transmits. Powering it directly from the ESP32's 3.3 V pin **without a
> capacitor** is the #1 cause of `FAIL` / unstable results. The module is **3.3 V only** —
> never connect VCC to 5 V.
---
## 🔌 Wiring (nRF24L01+ → ESP32)
The ESP32 uses its hardware **VSPI** bus. The SPI pins are fixed; `CE` and `CSN`
are user-selectable (defaults below).
| nRF24L01+ pin | Function | ESP32 pin |
|---------------|---------------------|------------------------|
| 1 · GND | Ground | **GND** |
| 2 · VCC | Power **3.3 V only**| **3V3** |
| 3 · CE | Chip Enable | **GPIO 4** |
| 4 · CSN | SPI Chip Select | **GPIO 5** |
| 5 · SCK | SPI Clock | **GPIO 18** (VSPI SCK) |
| 6 · MOSI | Master Out | **GPIO 23** (VSPI MOSI)|
| 7 · MISO | Master In | **GPIO 19** (VSPI MISO)|
| 8 · IRQ | Interrupt | *not connected* |
```
nRF24L01+ (top view, pins facing you)
+-----------------+
8 | IRQ MISO | 7
6 | MOSI SCK | 5
4 | CSN CE | 3
2 | VCC GND | 1
+--------[ ant ]--+
```
Add the capacitor as close to the module's VCC/GND pins as possible:
```
3V3 ──┬──────── VCC (nRF24)
│
═╪═ 10–100 µF (+ leg to VCC)
│
GND ──┴──────── GND (nRF24)
```
You can change `CE` / `CSN` in the sketch:
```cpp
#define CE_PIN 4 // Chip Enable
#define CSN_PIN 5 // SPI Chip Select
```
---
## ▶️ Usage
1. Power the ESP32. It runs a self-test immediately at boot.
2. On your phone/laptop, connect to the open WiFi network **`ESP32-nRF24-Test`**.
3. The captive portal page should pop up automatically.
If not, open a browser and go to **http://192.168.4.1**
4. Read the verdict:
- 🟩 **MODULE OK — ALL TESTS PASSED** → the module and wiring are good.
- 🟥 **MODULE FAULT** → follow the on-screen troubleshooting hints.
5. Fix any issue, then press **"Run test again"** to re-check.
---
## 🧪 What the tests mean
| Test | What it proves |
|-------------------------------|----------------------------------------------------------------------|
| SPI init (`radio.begin`) | The SPI bus started. |
| Chip responds (SPI link) | The chip actually answers. Fails on bad wiring, dead MISO, no power. |
| nRF24L01+ variant | It is a real "+" chip (not a broken clone). |
| Channel write/read-back | Both the write and read SPI paths work. |
| Data-rate 250 kbps write/read | The `+` low-rate mode is accepted — a strong health indicator. |
---
## 🩺 Troubleshooting
- **"Chip responds" fails** → check every SPI wire, common GND, and the 3.3 V supply.
- **Random / intermittent FAIL** → almost always **power**: add the 10–100 µF capacitor
or use a dedicated nRF24 adapter board.
- **"Variant" fails but chip responds** → likely a counterfeit or damaged module.
- **Nothing on SPI** → confirm SCK=18, MISO=19, MOSI=23, CE=4, CSN=5 and that the
module is 3.3 V (not 5 V).