-
Notifications
You must be signed in to change notification settings - Fork 25
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 13 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,58 @@ | ||
| # 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. | ||
|
|
||
| ## 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_logging` is enabled in the config, stdout is redirected to a file | ||
finger563 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
| ``` | ||
|
|
||
| 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,97 @@ | ||
| # 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. | ||
|
|
||
| ## 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 | ||
|
|
||
| ``` | ||
| I (380) Remote Debug Example: Starting Remote Debug Example | ||
| I (390) Remote Debug Example: Connecting to WiFi: MyNetwork | ||
| I (2450) Remote Debug Example: WiFi connected! IP: 192.168.1.105 | ||
| I (2456) Remote Debug Example: Initialized 2 ADC channels | ||
| I (2461) Remote Debug Example: Remote Debug Server started | ||
| I (2462) Remote Debug Example: Web interface: http://192.168.1.105:8080 | ||
| I (2463) Remote Debug Example: GPIO pins: 4 | ADC channels: 2 | ||
| ``` | ||
|
|
||
| ## 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 /data - Batched update (GPIO states + ADC data) | ||
| GET /gpio - List all GPIOs and current states | ||
| POST /gpio/direction - Set GPIO direction (input/output) | ||
| POST /gpio/set - Set GPIO output state | ||
finger563 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| GET /adc - Get current ADC values | ||
| GET /logs - Get console log content (if enabled) | ||
finger563 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
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.
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.