Test firmware for ESP32 with automatic notifications, sensor simulation, and mesh relay emulation.
This firmware is designed for testing the Beacon mobile application - a mesh network emergency communication system. The ESP32 acts as a BLE beacon node to validate mobile app functionality, BLE communication, and mesh network protocols.
- Main Project: github.com/goodmartian/beacon
- Project Website: goodmartian.github.io/beacon-site
✅ Automatic notifications - Test data broadcast every 10 seconds ✅ Sensor simulation - Battery, RSSI, temperature, humidity ✅ Test commands - GET_STATUS, SEND_SOS, ENABLE/DISABLE_AUTO ✅ Mesh relay emulation - Simulates mesh network message forwarding ✅ JSON format - All data in JSON for parsing validation ✅ Detailed logging - Comprehensive Serial Monitor output
- ESP32 DevKit (WROOM-32 or compatible)
- PlatformIO
- USB Micro cable
# Verify connection
ls /dev/ttyUSB* /dev/ttyACM*cd esp32-firmware
platformio run --target uploadplatformio device monitorEdit src/main.cpp to configure:
#define DEVICE_NAME "BEACON-NODE-001" // Device name
#define SERVICE_UUID "..." // Service UUID (from Flutter app)UUIDs must match the Flutter application (lib/core/constants/ble_constants.dart):
- Service UUID:
0000180a-0000-1000-8000-00805f9b34fb - Message Characteristic:
00002a58-0000-1000-8000-00805f9b34fb - Device ID Characteristic:
00002a29-0000-1000-8000-00805f9b34fb
- Fast blink (5 times): Initialization complete
- Solid on: Device connected
- 3 fast blinks: Message received
- Single flash every 2 sec: Waiting for connection
Send text commands from the Flutter app:
| Command | Description | Response |
|---|---|---|
GET_STATUS |
Get device status | JSON with battery, rssi, messages, relays, uptime |
SEND_SOS |
Generate SOS message | JSON with type:SOS, coordinates, timestamp |
ENABLE_AUTO |
Enable automatic notifications | Confirmation in Serial |
DISABLE_AUTO |
Disable automatic notifications | Confirmation in Serial |
RESET_STATS |
Reset counters | Reset messageCounter and relayCounter |
Every 10 seconds (when enabled):
{
"type": "auto",
"device": "BEACON-NODE-001",
"battery": 95.3,
"rssi": -65,
"counter": 42,
"timestamp": 1234567,
"temp": 22.5,
"humidity": 55
}{
"device": "BEACON-NODE-001",
"battery": 95.3,
"rssi": -65,
"messages": 42,
"relays": 15,
"uptime": 3600,
"autoNotify": true
}{
"type": "SOS",
"from": "BEACON-NODE-001",
"lat": 37.7749,
"lon": -122.4194,
"timestamp": 1234567,
"battery": 95.3
}- Upload firmware to ESP32
- Open Serial Monitor:
platformio device monitor - Open Beacon app on smartphone
- Find "BEACON-NODE-001" via BLE scan
- Connect to device
- Send commands from app
- Observe automatic notifications every 10 seconds
- Check detailed logs in Serial Monitor
# Add user to dialout group
sudo usermod -a -G dialout $USER
# Logout and login againPress and hold the BOOT button on ESP32 during firmware upload.
To test mesh network with multiple nodes:
#define DEVICE_NAME "BEACON-NODE-002"#define DEVICE_NAME "BEACON-NODE-003"Process:
- Edit
DEVICE_NAMEinsrc/main.cpp - Build:
platformio run - Connect second ESP32
- Upload:
platformio run --target upload - Repeat for third node
Mesh Testing:
- Connect app to NODE-001
- Send message
- NODE-001 emulates relay in Serial Monitor
- Reconnect to NODE-002/003 for testing
For parallel monitoring of multiple ESP32 devices:
# Terminal 1
platformio device monitor --port /dev/ttyUSB0
# Terminal 2
platformio device monitor --port /dev/ttyUSB1
# Terminal 3
platformio device monitor --port /dev/ttyUSB2Firmware automatically simulates:
- Battery: Decreases from 100% to 10%, then resets
- RSSI: Random values from -80 to -30 dBm
- Temperature: 15-25°C with variation
- Humidity: 30-70% with variation
- Counters: messageCounter, relayCounter
MIT