-
Notifications
You must be signed in to change notification settings - Fork 24
feat(remote_debug): Add new RemoteDebug component for WiFi GPIO/ADC and logfile access
#589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
62d1297
feat(remote_debug): Add new RemoteDebug component
finger563 7d057dd
Merge branch 'main' into feat/remote_debug
finger563 cb58bfc
update kconfig to default to saved ssid; update example / code to bet…
finger563 3d46582
update to allow labels in kconfig
finger563 6688c84
Working remote logging with colorization :)
finger563 61587ff
finalizing the component
finger563 ee1bf8b
cleanup
finger563 a7cf223
wip better analog plotting
finger563 f019d1b
improve behavior / performance
finger563 958bbf7
minor updates for good common config
finger563 0f61fef
clean up component
finger563 8a1f1e1
update ci and doc
finger563 0825d09
readme: update
finger563 fe4ba80
fix sa
finger563 98389e8
readme: update
finger563 e0a1ecf
address comments and improve behavior
finger563 dd62530
fix reamdes
finger563 050afea
fix doc
finger563 02b7a83
fix sa
finger563 8e911b3
comment update
finger563 9cc5e98
final cleanup
finger563 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| idf_component_register( | ||
| INCLUDE_DIRS "include" | ||
| SRC_DIRS "src" | ||
| REQUIRES esp_http_server driver adc base_component file_system timer | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Remote Debug | ||
|
|
||
| [](https://components.espressif.com/components/espp/remote_debug) | ||
|
|
||
| Web-based remote debugging interface providing GPIO control, real-time ADC | ||
| monitoring, and optional console log viewing over HTTP. Uses `espp::Timer` for | ||
| efficient, configurable periodic updates. | ||
|
|
||
| https://github.com/user-attachments/assets/ee806c6c-0f6b-4dd0-a5b0-82b80410b5bc | ||
|
|
||
| <img width="607" height="2048" alt="image" src="https://github.com/user-attachments/assets/5977033c-eee8-4be2-a9c4-634fd3100480" /> | ||
|
|
||
| ## Features | ||
|
|
||
| - **GPIO Control**: Configure pins as input/output, read states, control outputs via web interface | ||
| - **ADC Monitoring**: Real-time visualization of ADC channels with configurable sample rates | ||
| - **Console Log Viewer**: Optional stdout redirection to web-viewable log with ANSI color support | ||
| - **Efficient Updates**: Uses `espp::Timer` for optimal performance with configurable priority | ||
| - **RESTful API**: JSON endpoints for programmatic access | ||
| - **Responsive UI**: Modern web interface that works on desktop and mobile | ||
| - **Multi-client Support**: Optimized for multiple concurrent clients through batched updates | ||
|
|
||
| ## Performance | ||
|
|
||
| The component has been optimized for efficiency: | ||
|
|
||
| - Uses `espp::Timer` for precise, lightweight periodic updates | ||
| - Configurable task priority and stack size | ||
| - Batched ADC data updates reduce HTTP overhead | ||
| - Ring buffer implementation for efficient data management | ||
| - Efficient JSON generation minimizes processing overhead | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - `espp::Timer` - Periodic task execution | ||
| - `espp::Adc` - ADC channel management | ||
| - `espp::FileSystem` - LittleFS for optional log storage | ||
| - ESP HTTP Server - Web interface hosting | ||
|
|
||
| ## Console Logging | ||
|
|
||
| When `enable_log_capture` is enabled in the config, stdout is redirected to a file | ||
| viewable in the web interface. The log viewer supports ANSI color codes. | ||
|
|
||
| **Important**: For real-time log updates, enable LittleFS file flushing: | ||
|
|
||
| ``` | ||
| CONFIG_LITTLEFS_FLUSH_FILE_EVERY_WRITE=y | ||
| ``` | ||
|
|
||
| ## API Endpoints | ||
|
|
||
| The component exposes the following HTTP endpoints: | ||
|
|
||
| - `GET /` - Main web interface (HTML page) | ||
| - `GET /api/gpio/get` - Get all GPIO states and configurations (JSON) | ||
| - `POST /api/gpio/set` - Set GPIO output state (JSON: `{"pin": N, "value": 0|1}`) | ||
| - `POST /api/gpio/config` - Configure GPIO direction (JSON: `{"pin": N, "mode": 1|3}`) | ||
| - Mode values: `1` = INPUT, `3` = INPUT_OUTPUT (OUTPUT is promoted to INPUT_OUTPUT for safety) | ||
| - `GET /api/adc/data` - Get ADC readings and plot data (JSON with ring buffer indices) | ||
| - `GET /api/logs` - Get console log contents (text/plain with ANSI colors) | ||
| - `POST /api/logs/start` - Start log capture (redirects stdout to file) | ||
| - `POST /api/logs/stop` - Stop log capture (restores stdout to /dev/console) | ||
|
|
||
| Set this in your `sdkconfig.defaults` or via `idf.py menuconfig` → Component | ||
| config → LittleFS. Without this, logs only appear after the buffer fills. | ||
|
|
||
| ## Example | ||
|
|
||
| See the example in the `example/` folder for a complete demonstration with WiFi | ||
| connection, GPIO control, ADC monitoring, and console log viewing. | ||
|
|
||
| ## External Resources | ||
|
|
||
| - [ESP-IDF HTTP Server Documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/esp_http_server.html) | ||
| - [ADC Continuous Mode](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc_continuous.html) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # The following lines of boilerplate have to be in your project's CMakeLists | ||
| # in this exact order for cmake to work correctly | ||
| cmake_minimum_required(VERSION 3.20) | ||
|
|
||
| set(ENV{IDF_COMPONENT_MANAGER} "0") | ||
| include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
|
|
||
| # add the component directories that we want to use | ||
| set(EXTRA_COMPONENT_DIRS | ||
| "../../../components/" | ||
| ) | ||
|
|
||
| set( | ||
| COMPONENTS | ||
| "main esptool_py remote_debug task timer nvs_flash wifi" | ||
| CACHE STRING | ||
| "List of components to include" | ||
| ) | ||
|
|
||
| project(remote_debug_example) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 20) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Remote Debug Example | ||
|
|
||
| This example demonstrates the `espp::RemoteDebug` component, providing a | ||
| web-based interface for GPIO control, real-time ADC monitoring, and console log | ||
| viewing. | ||
|
|
||
| https://github.com/user-attachments/assets/ee806c6c-0f6b-4dd0-a5b0-82b80410b5bc | ||
|
|
||
| <img width="607" height="2048" alt="image" src="https://github.com/user-attachments/assets/5977033c-eee8-4be2-a9c4-634fd3100480" /> | ||
|
|
||
| ## How to use example | ||
|
|
||
| ### Hardware Required | ||
|
|
||
| This example can run on any ESP32 development board. For testing: | ||
| - Connect LEDs or other peripherals / inputs to GPIO pins | ||
| - Connect analog sensors to ADC-capable pins | ||
|
|
||
| ### Configure the project | ||
|
|
||
| ``` | ||
| idf.py menuconfig | ||
| ``` | ||
|
|
||
| Navigate to `Remote Debug Example Configuration`: | ||
| - WiFi credentials (SSID and password) | ||
| - Server configuration (port, title) | ||
| - GPIO configuration (number of pins, pin numbers, labels) | ||
| - ADC configuration (channels, attenuation, labels, sample rate, buffer size) | ||
| - Console logging (enable/disable, buffer size) | ||
|
|
||
| **Important**: If enabling console logging, you must also set: | ||
| - Component config → LittleFS → `CONFIG_LITTLEFS_FLUSH_FILE_EVERY_WRITE=y` | ||
|
|
||
| This ensures real-time log updates on the web interface. | ||
|
|
||
| ### Build and Flash | ||
|
|
||
| Build the project and flash it to the board, then run monitor tool to view serial output: | ||
|
|
||
| ``` | ||
| idf.py -p PORT flash monitor | ||
| ``` | ||
|
|
||
| (Replace PORT with the name of the serial port to use.) | ||
|
|
||
| (To exit the serial monitor, type ``Ctrl-]``.) | ||
|
|
||
| See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. | ||
|
|
||
| ### Access the Interface | ||
|
|
||
| 1. Device connects to configured WiFi network | ||
| 2. Check serial monitor for assigned IP address | ||
| 3. Open web browser to `http://<device-ip>:<port>` (default port: 8080) | ||
| 4. Use the interface to control GPIOs, monitor ADCs, and view console logs | ||
|
|
||
| ## Example Output | ||
|
|
||
| <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" /> | ||
|
|
||
| Screenshots: | ||
| <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" /> | ||
| <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" /> | ||
|
|
||
| ## Web Interface Features | ||
|
|
||
| - **GPIO Control** | ||
| - Configure pins as input or output | ||
| - Read current states in real-time | ||
| - Set output pins HIGH or LOW | ||
| - Visual state indicators | ||
|
|
||
| - **ADC Monitoring** | ||
| - Real-time plotting with automatic updates | ||
| - Multiple channels displayed simultaneously | ||
| - Voltage display (converted from raw values) | ||
| - Configurable sample rate and buffer size | ||
|
|
||
| - **Console Log Viewer** (when enabled) | ||
| - Live stdout output | ||
| - ANSI color code support | ||
| - Auto-scrolling display | ||
| - Configurable buffer size | ||
|
|
||
| ## API Endpoints | ||
|
|
||
| Programmatic access via JSON REST API: | ||
|
|
||
| ``` | ||
| GET /api/gpio/get - Get all GPIO states and configurations | ||
| POST /api/gpio/set - Set GPIO output state (JSON: {"pin": N, "value": 0|1}) | ||
| POST /api/gpio/config - Configure GPIO direction (JSON: {"pin": N, "mode": 1|3}) | ||
| GET /api/adc/data - Get ADC readings and plot data | ||
| POST /api/logs/start - Start log capture (redirects stdout to file) | ||
| POST /api/logs/stop - Stop log capture (restores stdout to /dev/console) | ||
| GET /api/logs - Get console log content (text/plain with ANSI colors) | ||
| ``` | ||
|
|
||
| Note: GPIO mode values are `1` for INPUT and `3` for INPUT_OUTPUT. OUTPUT mode (2) is automatically promoted to INPUT_OUTPUT for safety. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| idf_component_register(SRC_DIRS "." | ||
| INCLUDE_DIRS "." | ||
| PRIV_REQUIRES remote_debug wifi nvs file_system timer) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.