|
| 1 | +# Remote Debug Example |
| 2 | + |
| 3 | +This example demonstrates the `espp::RemoteDebug` component, providing a |
| 4 | +web-based interface for GPIO control, real-time ADC monitoring, and console log |
| 5 | +viewing. |
| 6 | + |
| 7 | +https://github.com/user-attachments/assets/ee806c6c-0f6b-4dd0-a5b0-82b80410b5bc |
| 8 | + |
| 9 | +<img width="607" height="2048" alt="image" src="https://github.com/user-attachments/assets/5977033c-eee8-4be2-a9c4-634fd3100480" /> |
| 10 | + |
| 11 | +## How to use example |
| 12 | + |
| 13 | +### Hardware Required |
| 14 | + |
| 15 | +This example can run on any ESP32 development board. For testing: |
| 16 | +- Connect LEDs or other peripherals / inputs to GPIO pins |
| 17 | +- Connect analog sensors to ADC-capable pins |
| 18 | + |
| 19 | +### Configure the project |
| 20 | + |
| 21 | +``` |
| 22 | +idf.py menuconfig |
| 23 | +``` |
| 24 | + |
| 25 | +Navigate to `Remote Debug Example Configuration`: |
| 26 | +- WiFi credentials (SSID and password) |
| 27 | +- Server configuration (port, title) |
| 28 | +- GPIO configuration (number of pins, pin numbers, labels) |
| 29 | +- ADC configuration (channels, attenuation, labels, sample rate, buffer size) |
| 30 | +- Console logging (enable/disable, buffer size) |
| 31 | + |
| 32 | +**Important**: If enabling console logging, you must also set: |
| 33 | +- Component config → LittleFS → `CONFIG_LITTLEFS_FLUSH_FILE_EVERY_WRITE=y` |
| 34 | + |
| 35 | +This ensures real-time log updates on the web interface. |
| 36 | + |
| 37 | +### Build and Flash |
| 38 | + |
| 39 | +Build the project and flash it to the board, then run monitor tool to view serial output: |
| 40 | + |
| 41 | +``` |
| 42 | +idf.py -p PORT flash monitor |
| 43 | +``` |
| 44 | + |
| 45 | +(Replace PORT with the name of the serial port to use.) |
| 46 | + |
| 47 | +(To exit the serial monitor, type ``Ctrl-]``.) |
| 48 | + |
| 49 | +See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. |
| 50 | + |
| 51 | +### Access the Interface |
| 52 | + |
| 53 | +1. Device connects to configured WiFi network |
| 54 | +2. Check serial monitor for assigned IP address |
| 55 | +3. Open web browser to `http://<device-ip>:<port>` (default port: 8080) |
| 56 | +4. Use the interface to control GPIOs, monitor ADCs, and view console logs |
| 57 | + |
| 58 | +## Example Output |
| 59 | + |
| 60 | +<img width="1396" height="460" alt="CleanShot 2026-01-27 at 00 13 39@2x" src="https://github.com/user-attachments/assets/bc129b24-24c0-4ed0-9976-33035eef5630" /> |
| 61 | + |
| 62 | +Screenshots: |
| 63 | +<img width="1764" height="2274" alt="CleanShot 2026-01-27 at 00 12 32@2x" src="https://github.com/user-attachments/assets/5a22eb67-8cad-468e-b214-117ff70ed73e" /> |
| 64 | +<img width="1764" height="2274" alt="CleanShot 2026-01-27 at 00 13 06@2x" src="https://github.com/user-attachments/assets/f893a8b2-35f6-4bc6-81ca-24e500e12232" /> |
| 65 | + |
| 66 | +## Web Interface Features |
| 67 | + |
| 68 | +- **GPIO Control** |
| 69 | + - Configure pins as input or output |
| 70 | + - Read current states in real-time |
| 71 | + - Set output pins HIGH or LOW |
| 72 | + - Visual state indicators |
| 73 | + |
| 74 | +- **ADC Monitoring** |
| 75 | + - Real-time plotting with automatic updates |
| 76 | + - Multiple channels displayed simultaneously |
| 77 | + - Voltage display (converted from raw values) |
| 78 | + - Configurable sample rate and buffer size |
| 79 | + |
| 80 | +- **Console Log Viewer** (when enabled) |
| 81 | + - Live stdout output |
| 82 | + - ANSI color code support |
| 83 | + - Auto-scrolling display |
| 84 | + - Configurable buffer size |
| 85 | + |
| 86 | +## API Endpoints |
| 87 | + |
| 88 | +Programmatic access via JSON REST API: |
| 89 | + |
| 90 | +``` |
| 91 | +GET /api/gpio/get - Get all GPIO states and configurations |
| 92 | +POST /api/gpio/set - Set GPIO output state (JSON: {"pin": N, "value": 0|1}) |
| 93 | +POST /api/gpio/config - Configure GPIO direction (JSON: {"pin": N, "mode": 1|3}) |
| 94 | +GET /api/adc/data - Get ADC readings and plot data |
| 95 | +POST /api/logs/start - Start log capture (redirects stdout to file) |
| 96 | +POST /api/logs/stop - Stop log capture (restores stdout to /dev/console) |
| 97 | +GET /api/logs - Get console log content (text/plain with ANSI colors) |
| 98 | +``` |
| 99 | + |
| 100 | +Note: GPIO mode values are `1` for INPUT and `3` for INPUT_OUTPUT. OUTPUT mode (2) is automatically promoted to INPUT_OUTPUT for safety. |
0 commit comments