{"id":105247,"date":"2021-08-10T15:12:24","date_gmt":"2021-08-10T15:12:24","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=105247"},"modified":"2021-08-12T10:27:24","modified_gmt":"2021-08-12T10:27:24","slug":"esp32-webserial-library","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-webserial-library\/","title":{"rendered":"ESP32 WebSerial: Web-based Remote Serial Monitor"},"content":{"rendered":"\n<p>In this guide, you&#8217;ll learn how to create and use a web-based &#8220;Serial Monitor&#8221; for your ESP32 projects using the WebSerial library. This creates a web-based interface to output debugging messages, as you would do with a regular serial monitor. You can also send messages from the web-based serial monitor to the ESP32.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/ESP32-WebSerial-Remote-Serial-Monitor-Web-basedl.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 WebSerial Web-based Remote Serial Monitor Arduino Core IDE\" class=\"wp-image-105309\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/ESP32-WebSerial-Remote-Serial-Monitor-Web-basedl.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/ESP32-WebSerial-Remote-Serial-Monitor-Web-basedl.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/ESP32-WebSerial-Remote-Serial-Monitor-Web-basedl.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/ESP32-WebSerial-Remote-Serial-Monitor-Web-basedl.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n\n<p>We have a similar tutorial for the ESP8266 board: <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-webserial-library\/\">ESP8266 NodeMCU WebSerial Web-based Remote Serial Monitor <\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Web-based Serial Monitor<\/h2>\n\n\n\n<p>In most of your ESP32 projects, you use the serial monitor to output debugging messages that help you better understand what&#8217;s happening with the microcontroller.<\/p>\n\n\n\n<p>You create a Serial communication between your board and your computer, and then you can visualize the messages using the serial monitor. However, when your board is not connected to your computer, you can&#8217;t see the debugging messages. <\/p>\n\n\n\n<p>A workaround for this issue is to use a web-based serial monitor\u2014the ESP32 hosts a web server that serves a page to visualize the messages as you would with the &#8220;regular&#8221; serial monitor. The WebSerial web page also allows you to send data from the web page to your board.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"508\" height=\"499\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/WebSerial-library-ESP32-ESP8266.png?resize=508%2C499&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"WebSerial Library ESP32 ESP8266 web-based Serial Monitor\" class=\"wp-image-105259\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/WebSerial-library-ESP32-ESP8266.png?w=508&amp;quality=100&amp;strip=all&amp;ssl=1 508w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/WebSerial-library-ESP32-ESP8266.png?resize=300%2C295&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 508px) 100vw, 508px\" \/><\/figure><\/div>\n\n\n\n<p>For this tutorial, we&#8217;ll use the <a href=\"https:\/\/github.com\/ayushsharma82\/WebSerial\" target=\"_blank\" rel=\"noreferrer noopener\">WebSerial library<\/a>.<\/p>\n\n\n\n<p class=\"rntbox rntclgray\">If you like this library and you&#8217;ll use it in your projects, consider <a href=\"https:\/\/github.com\/ayushsharma82\/WebSerial#contributions\" target=\"_blank\" rel=\"noreferrer noopener\">supporting the developer&#8217;s work<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">WebSerial Features<\/h3>\n\n\n\n<p>List of WebSerial features:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Works on WebSockets;<\/li><li>Realtime logging;<\/li><li>Any number of serial monitors can be opened on the browser;<\/li><li>Uses <a href=\"https:\/\/github.com\/me-no-dev\/ESPAsyncWebServer\" target=\"_blank\" rel=\"noreferrer noopener\">AsyncWebserver<\/a> for better performance.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">WebSerial Functions<\/h3>\n\n\n\n<p>Using WebSerial is similar to use the serial monitor. Its main functions are <span class=\"rnthl rntliteral\">print()<\/span> and <span class=\"rnthl rntliteral\">println()<\/span>:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><span class=\"rnthl rntliteral\">print()<\/span>: prints the data on the web-based serial monitor without newline character (on the same line);<\/li><li><span class=\"rnthl rntliteral\">println()<\/span>: prints the data on the web-based serial monitor with a newline character (on the next line);<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the WebSerial Library<\/h2>\n\n\n\n<p>For this project, we&#8217;ll use the <a href=\"https:\/\/github.com\/ayushsharma82\/WebSerial\" target=\"_blank\" rel=\"noreferrer noopener\">WebSerial.h library<\/a>. To install the library:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>In your Arduino IDE, go to <strong>Sketch<\/strong> &gt; <strong>Include Library<\/strong> &gt; <strong>Manage Libraries&#8230;<\/strong><\/li><li>Search for <em>webserial<\/em>.<\/li><li>Install the WebSerial library by Ayush Sharma.<\/li><\/ol>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"786\" height=\"443\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/Install-Web-Serial-Library.png?resize=786%2C443&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing Web Serial Library Arduino IDE\" class=\"wp-image-105250\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/Install-Web-Serial-Library.png?w=786&amp;quality=100&amp;strip=all&amp;ssl=1 786w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/Install-Web-Serial-Library.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/Install-Web-Serial-Library.png?resize=768%2C433&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/figure><\/div>\n\n\n\n<p>You also need to install the <a href=\"https:\/\/github.com\/me-no-dev\/ESPAsyncWebServer\" target=\"_blank\" rel=\"noreferrer noopener\">ESPAsyncWebServer <\/a>and the <a href=\"https:\/\/github.com\/me-no-dev\/AsyncTCP\" target=\"_blank\" rel=\"noreferrer noopener\">AsyncTCP<\/a> libraries. Click the following links to download the libraries&#8217; files.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/me-no-dev\/ESPAsyncWebServer\/archive\/refs\/heads\/master.zip\" target=\"_blank\" rel=\"noreferrer noopener\">ESPAsyncWebServer<\/a><\/li><li><a href=\"https:\/\/github.com\/me-no-dev\/AsyncTCP\/archive\/refs\/heads\/master.zip\" target=\"_blank\" rel=\"noreferrer noopener\">AsyncTCP<\/a><\/li><\/ul>\n\n\n\n<p>To install these libraries, click on the previous links to download the libraries&#8217; files. Then, in your Arduino IDE, go to <strong>Sketch <\/strong>&gt; <strong>Include Library<\/strong> &gt; <strong>Add .ZIP Library&#8230;<\/strong><\/p>\n\n\n\n<p>If you\u2019re using VS Code with the PlatformIO extension, copy the following to the&nbsp;<span class=\"rnthl rntliteral\">platformio.ini<\/span>&nbsp;file to include the libraries.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lib_deps = ESP Async WebServer\n  ayushsharma82\/WebSerial @ ^1.1.0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">ESP32 WebSerial Example<\/h2>\n\n\n\n<p>The library provides a simple example about creating the Web Serial Monitor to output and receive messages. We&#8217;ve modified the example a bit to make it more interactive.<\/p>\n\n\n\n<p>This example prints <span class=\"rnthl rntliteral\">Hello!<\/span> to the web-based serial monitor every two seconds. Additionally, you can send messages from the web-based serial monitor to the board. You can send the message <span class=\"rnthl rntliteral\">ON<\/span> to light up the board&#8217;s built-in LED or the message <span class=\"rnthl rntliteral\">OFF<\/span> to turn it off.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp32-webserial-library\/\n  \n  This sketch is based on the WebSerial library example: ESP32_Demo\n  https:\/\/github.com\/ayushsharma82\/WebSerial\n*\/\n\n#include &lt;Arduino.h&gt;\n#include &lt;WiFi.h&gt;\n#include &lt;AsyncTCP.h&gt;\n#include &lt;ESPAsyncWebServer.h&gt;\n#include &lt;WebSerial.h&gt;\n\n#define LED 2\n\nAsyncWebServer server(80);\n\nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;          \/\/ Your WiFi SSID\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;  \/\/ Your WiFi Password\n\nvoid recvMsg(uint8_t *data, size_t len){\n  WebSerial.println(&quot;Received Data...&quot;);\n  String d = &quot;&quot;;\n  for(int i=0; i &lt; len; i++){\n    d += char(data[i]);\n  }\n  WebSerial.println(d);\n  if (d == &quot;ON&quot;){\n    digitalWrite(LED, HIGH);\n  }\n  if (d==&quot;OFF&quot;){\n    digitalWrite(LED, LOW);\n  }\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  pinMode(LED, OUTPUT);\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n  if (WiFi.waitForConnectResult() != WL_CONNECTED) {\n    Serial.printf(&quot;WiFi Failed!\\n&quot;);\n    return;\n  }\n  Serial.print(&quot;IP Address: &quot;);\n  Serial.println(WiFi.localIP());\n  \/\/ WebSerial is accessible at &quot;&lt;IP Address&gt;\/webserial&quot; in browser\n  WebSerial.begin(&amp;server);\n  WebSerial.msgCallback(recvMsg);\n  server.begin();\n}\n\nvoid loop() {\n  WebSerial.println(&quot;Hello!&quot;);\n  delay(2000);\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP32\/ESP32_WebSerial.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>Before uploading the code to your board, don&#8217;t forget to insert your network credentials.<\/p>\n\n\n\n<p>In this example, the ESP32 is in station mode. This example also works in access point mode. To learn how to set up your ESP32 as an access point, read:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-access-point-ap-web-server\/\">How to Set an ESP32 Access Point (AP) for Web Server<\/a><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>Continue reading to learn how the code works or skip to the <a href=\"#demonstration-1\">demonstration section<\/a>.<\/p>\n\n\n\n<p>First, you need to include the required libraries for WebSerial. The <span class=\"rnthl rntliteral\">WiFi.h<\/span> library is needed to connect the ESP32 to a Wi-Fi network.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;WiFi.h&gt;<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">WebSerial<\/span> library uses the <span class=\"rnthl rntliteral\">AsyncTCP<\/span> and the <span class=\"rnthl rntliteral\">ESPAsyncWebServer<\/span> libraries to create the web-based serial monitor. <\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;AsyncTCP.h&gt;\n#include &lt;ESPAsyncWebServer.h&gt;<\/code><\/pre>\n\n\n\n<p>Finally, the <span class=\"rnthl rntliteral\">WebSerial<\/span> library provides easy methods to build the web-based serial monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;WebSerial.h&gt;<\/code><\/pre>\n\n\n\n<p>Create a variable called <span class=\"rnthl rntliteral\">LED<\/span> for the built-in LED on GPIO 2.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define LED 2<\/code><\/pre>\n\n\n\n<p>Initialize an <span class=\"rnthl rntliteral\">AsyncWebServer<\/span> object on port 80 to set up the web server.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>AsyncWebServer server(80);<\/code><\/pre>\n\n\n\n<p>Insert your network credentials in the following variables:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* ssid = \"REPLACE_WITH_YOUR_SSID\"; \/\/ Your WiFi SSID\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\"; \/\/ Your WiFi Password<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Handling Received Messages<\/h4>\n\n\n\n<p>The following function receives incoming messages sent from the web-based serial monitor. The message is saved on the <span class=\"rnthl rntliteral\">d<\/span> variable. Then, it is printed on the web serial monitor using <span class=\"rnthl rntliteral\">WebSerial.println(d)<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void recvMsg(uint8_t *data, size_t len){\n  WebSerial.println(\"Received Data...\");\n  String d = \"\";\n  for(int i=0; i &lt; len; i++){\n    d += char(data&#091;i]);\n  }\n  WebSerial.println(d);<\/code><\/pre>\n\n\n\n<p>Next, we check if the content of the <span class=\"rnthl rntliteral\">d<\/span> variable is <span class=\"rnthl rntliteral\">ON<\/span> or <span class=\"rnthl rntliteral\">OFF<\/span> and light up the LED accordingly.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (d == \"ON\"){\n  digitalWrite(LED, HIGH);\n}\nif (d==\"OFF\"){\n  digitalWrite(LED, LOW);\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">setup()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, set the <span class=\"rnthl rntliteral\">LED<\/span> as an <span class=\"rnthl rntliteral\">OUTPUT<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(LED, OUTPUT);<\/code><\/pre>\n\n\n\n<p>Connect your board to your local network:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.mode(WIFI_STA);\nWiFi.begin(ssid, password);\nif (WiFi.waitForConnectResult() != WL_CONNECTED) {\n  Serial.printf(\"WiFi Failed!\\n\");\n  return;\n}\nSerial.print(\"IP Address: \");\nSerial.println(WiFi.localIP());<\/code><\/pre>\n\n\n\n<p>Initialize the web-based serial monitor with the <span class=\"rnthl rntliteral\">begin()<\/span> method on the <span class=\"rnthl rntliteral\">WebSerial<\/span> object. This function accepts as an argument an <span class=\"rnthl rntliteral\">AsyncWebServer<\/span> object.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WebSerial.begin(&amp;server);<\/code><\/pre>\n\n\n\n<p>Register the <span class=\"rnthl rntliteral\">recvMsg()<\/span> as a callback function using the <span class=\"rnthl rntliteral\">msgCallback()<\/span> method on the <span class=\"rnthl rntliteral\">WebSerial<\/span> object. The <span class=\"rnthl rntliteral\">recvMsg()<\/span> function will run whenever you send a message from the monitor to the board.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WebSerial.msgCallback(recvMsg);<\/code><\/pre>\n\n\n\n<p>Finally, initialize the server.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>server.begin();<\/code><\/pre>\n\n\n\n<p>It is just after calling this line that the web-based serial monitor will start working.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">loop()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, print the <span class=\"rnthl rntliteral\">Hello!<\/span> message every 2000 milliseconds (2 seconds) using the <span class=\"rnthl rntliteral\">println()<\/span> function on the <span class=\"rnthl rntliteral\">WebSerial<\/span> object.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void loop() {\n  WebSerial.println(\"Hello!\");\n  delay(2000);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"demonstration-1\">Demonstration<\/h2>\n\n\n\n<p>After inserting your network credentials, you can upload the code to your board.<\/p>\n\n\n\n<p>After uploading, open the &#8220;regular&#8221; serial monitor at a baud rate of 115200. The board&#8217;s IP address will be printed.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"525\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/get-IP-address.png?resize=601%2C525&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 WebSerial Web-based Remote Serial Monitor Arduino IDE Demonstration\" class=\"wp-image-105263\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/get-IP-address.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/get-IP-address.png?resize=300%2C262&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<p>Now, open a browser on your local network and type the ESP IP address followed by <span class=\"rnthl rntliteral\">\/webserial<\/span>. For example, in my case:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>192.168.1.85\/<strong>webserial<\/strong><\/code><\/pre>\n\n\n\n<p>The WebSerial page should load.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"604\" height=\"637\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/testing-webserial-basic-example-demonstration.png?resize=604%2C637&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Testing Web Serial Library Basic Example Demonstration\" class=\"wp-image-105264\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/testing-webserial-basic-example-demonstration.png?w=604&amp;quality=100&amp;strip=all&amp;ssl=1 604w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/testing-webserial-basic-example-demonstration.png?resize=284%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 284w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/figure><\/div>\n\n\n\n<p>As you can see, it is printing <span class=\"rnthl rntliteral\">Hello!<\/span> every two seconds. Additionally, you can send commands to the ESP32. All the commands that you send are printed back on the web serial monitor. You can send the <span class=\"rnthl rntliteral\">ON<\/span> and <span class=\"rnthl rntliteral\">OFF<\/span> commands to control the built-in LED.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 board Built in LED turned on HIGH\" class=\"wp-image-96167\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<p>This was just a simple example showing how you can use the WebSerial library to create a web-based serial monitor to send and receive data.<\/p>\n\n\n\n<p>Now, you can easily add a web-based serial monitor to any of your projects using the <a href=\"https:\/\/github.com\/ayushsharma82\/WebSerial\" target=\"_blank\" rel=\"noreferrer noopener\">WebSerial library<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this quick tutorial, you learned how to create a web-based serial monitor. This is especially useful if your project is not connected to your computer via Serial communication and you still want to visualize debugging messages. The communication between the web-based serial monitor and the ESP32 uses WebSocket protocol.<\/p>\n\n\n\n<p>We hope you find this tutorial useful. We have other web server tutorials you may like:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-web-server-sent-events-sse\/\">ESP32 Web Server using Server-Sent Events (Update Sensor Readings Automatically)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-websocket-server-arduino\/\">ESP32 WebSocket Server: Control Outputs (Arduino IDE)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-ota-over-the-air-arduino\/\">ESP32 OTA (Over-the-Air) Updates \u2013 AsyncElegantOTA using Arduino IDE<\/a><\/li><\/ul>\n\n\n\n<p>Learn more about the ESP32 with our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/build-web-servers-esp32-esp8266-ebook\/\"><strong>Build Web Servers with ESP32 and ESP8266 eBook<\/strong><\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE (eBook + video course)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">More ESP32 tutorials and projects\u2026<\/a><\/li><\/ul>\n\n\n\n<p>Thank you for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, you&#8217;ll learn how to create and use a web-based &#8220;Serial Monitor&#8221; for your ESP32 projects using the WebSerial library. This creates a web-based interface to output debugging &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32 WebSerial: Web-based Remote Serial Monitor\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-webserial-library\/#more-105247\" aria-label=\"Read more about ESP32 WebSerial: Web-based Remote Serial Monitor\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":105309,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[276,281,277,299,264],"tags":[],"class_list":["post-105247","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/07\/ESP32-WebSerial-Remote-Serial-Monitor-Web-basedl.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/105247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=105247"}],"version-history":[{"count":23,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/105247\/revisions"}],"predecessor-version":[{"id":105948,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/105247\/revisions\/105948"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/105309"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=105247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=105247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=105247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}