# esp32-GY-NEO6MV2-example

> Test GY-NEO6MV2 module and show results via captive portal.

- Author: Mikrobot.pl
- Platform: ESP32
- Board: ESP32 Dev Module (`esp32:esp32:esp32`)
- SDK version: 3.3.6
- Tags: #test, #esp32, #example, #captive portal, #wifi, #gy-neo6mv2
- Created: 2026-09-03
- Updated: 2026-09-03
- Favorites: 0, forks: 0
- Project page (view, flash from the browser, fork): https://flashesp.com/explore/1dYdRK15LlKLaivUFRXEt
- Download all sources (zip): https://flashesp.com/api/public-projects/1dYdRK15LlKLaivUFRXEt/download-sources/

## Source files

- [libraries_lock.json (90 B)](https://flashesp.com/explore/1dYdRK15LlKLaivUFRXEt/files/Uv0bcqvrWLQtj4soQHren.md)
- [main.ino (7.9 KB)](https://flashesp.com/explore/1dYdRK15LlKLaivUFRXEt/files/zct7Lks1fypcOktCHyp47.md)
- readme.md (3.5 KB)

## README

# ESP32 GPS Captive Portal
### View live GPS data over WiFi through a captive portal

This project turns an **ESP32 Dev Board** into a small WiFi-accessible GPS readout using a **GY-NEO6MV2 (u-blox NEO-6M)** module.
When powered, the ESP32 creates an **open WiFi Access Point** and a **captive portal**.
As soon as a device connects to the AP, a status page appears that shows **live GPS data** (fix status, satellites, position, altitude, speed and UTC time), auto-refreshing every second.

---

## ⭐ Features

- **Open WiFi Access Point** (no password)
  - SSID: `ESP32-GPS`
- **Captive portal**
  - Any URL request (e.g. `google.com`) is redirected to the GPS status page
  - Works with Android / iOS / Windows / Linux
- **Live GPS dashboard**
  - Fix status, satellite count, HDOP
  - Latitude / longitude, altitude, speed, course
  - UTC date & time
  - Auto-refresh every 1 second (AJAX, no page reload)
- **Disconnection detection**
  - If the module is unplugged (no data for 2 s), the page shows a clear **NO DATA** error instead of stale values
- **Privacy-friendly**
  - Coordinates are rounded to **2 decimal places (~1 km)** on the server, so exact location is never sent to the client
- No external network or internet required

---

## 📦 Hardware requirements

- **ESP32 Dev Board** (e.g. ESP32-DevKitC)
- **GY-NEO6MV2** GPS module (u-blox NEO-6M) with antenna

### Wiring (ESP32 ↔ NEO-6M)

| GPS module | ESP32     |
|------------|-----------|
| VCC        | 3V3       |
| GND        | GND       |
| TX         | GPIO16 (RX) |
| RX         | GPIO17 (TX) |

> **Note:** TX/RX are crossed — module **TX → ESP32 RX** and module **RX → ESP32 TX**.
> UART2 (GPIO16/17) is used so it does not conflict with the USB serial (UART0) used for programming and debugging.

Default GPS pins in the code:

```cpp
#define GPS_RX_PIN 16   // ESP32 RX  <- GPS TX
#define GPS_TX_PIN 17   // ESP32 TX  -> GPS RX
#define GPS_BAUD   9600
```

---


## 🚀 Getting started

1. Wire the GPS module to the ESP32 as shown above.
2. Open FlashESP project.
3. CLick "Flash to Device"
4. Choose port.
5. Click "Install main".
6. On your phone/laptop, connect to the WiFi network **`ESP32-GPS`** (open, no password).
7. The captive portal should open automatically. If not, open a browser and go to:

   ```
   http://192.168.4.1
   ```

7. Watch the live GPS data. The first fix may take **a few minutes** outdoors or near a window (indoors it often won't lock at all).

---

## 🔍 Troubleshooting

| Symptom | Likely cause / fix |
|---------|--------------------|
| **NO DATA from GPS** | Check wiring (TX/RX crossed), power, and that the module LED is present. Try baud `38400`. |
| Data flows but **Fix = NO** for a long time | Normal indoors — move the antenna near a window or outside and wait. |
| Garbage in serial monitor | Wrong baud rate — change `GPS_BAUD` to `38400`. |
| Module LED never blinks | No fix yet — it only blinks (~1 Hz) after locking a position. |

---

## ⚙️ Configuration

| Setting | Location | Description |
|---------|----------|-------------|
| `ap_ssid` | top of sketch | Access Point name |
| `GPS_RX_PIN` / `GPS_TX_PIN` | top of sketch | ESP32 UART pins for the GPS |
| `GPS_BAUD` | top of sketch | GPS serial speed (default 9600) |
| `GPS_TIMEOUT_MS` | top of sketch | How long without data before "NO DATA" is shown (default 2000 ms) |
| Coordinate precision | `gpsJson()` | `String(gps.location.lat(), 2)` — change `2` → `1` for coarser (~11 km), or higher for finer |

---

## 📄 License

Free to use and modify.
