Skip to content

circuitcode/AsyncWebSerial

Repository files navigation

AsyncWebSerial

AsyncWebSerial: Simplify ESP32 debugging and logging with seamless browser-based serial communication.

Features

  • Browser-Based Serial Access: Log and debug ESP32 microcontrollers directly from a web browser using the Web Serial API.
  • Real-Time Communication: Stream logs and data in real time, eliminating the need for traditional serial monitors.
  • Asynchronous Operation: Leverages asynchronous processing for smooth and efficient communication.
  • Cross-Platform Compatibility: Works on any browser that supports the Web Serial API, no additional software required.
  • Customizable Integration: Easily integrates into ESP32 projects, enabling tailored debugging and logging workflows.
  • User-Friendly Interface: Provides an intuitive way to monitor and interact with the ESP32 during development.

Dependencies

Build web interface

Install frontend dependencies:

yarn && yarn build

Implementation

Add AsyncWebSerial to your platformIO project platformio.ini

[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps =
    circuitcode/AsyncWebSerial

Include the library in your code

#include <AsyncWebSerial.h>

Initialize the library

AsyncWebServer server(80);
AsyncWebSerial webSerial;

Use the library

void setup() {
 webSerial.begin(&server);
 server.begin();
}

void loop() {
 webSerial.loop();
}

Send data to the AsyncWebSerial

webSerial.println("Hello, World!");
webSerial.printf("Hello, %s!", "World");

Receive data from the AsyncWebSerial

You can use the onMessage method to receive data from the AsyncWebSerial. The method accepts a callback function that will be called when data is received. The callback function can accept both const char * and String data types.

webSerial.onMessage([](const char *data, size_t len) {
  Serial.write(data, len);
});

webSerial.onMessage([](const String &msg) {
  Serial.println(msg);
});

Connect to the device serial page

Navigate to http://<device-ip>/webserial to access the serial page.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Browser-based logging and debugging for ESP32 using the Web Serial API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •