<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jesper Lindstrøm Nielsen on Medium]]></title>
        <description><![CDATA[Stories by Jesper Lindstrøm Nielsen on Medium]]></description>
        <link>https://medium.com/@jesper_24823?source=rss-168b8d4b3794------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*CeJjsMKZxup5n5Ex</url>
            <title>Stories by Jesper Lindstrøm Nielsen on Medium</title>
            <link>https://medium.com/@jesper_24823?source=rss-168b8d4b3794------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 01:33:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jesper_24823/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flash your ESP32 from the browser using Web Serial]]></title>
            <link>https://medium.com/the-toit-take/flash-your-esp32-from-the-browser-using-web-serial-5eccb1483b9c?source=rss-168b8d4b3794------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eccb1483b9c</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-serial]]></category>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Jesper Lindstrøm Nielsen]]></dc:creator>
            <pubDate>Tue, 06 Jul 2021 09:09:32 GMT</pubDate>
            <atom:updated>2021-07-06T09:09:32.367Z</atom:updated>
            <content:encoded><![CDATA[<p>The first step for users when onboarding the Toit platform is to initially flash the ESP32 with the Toit firmware, which will make all future updates available to send over the air without any serial connection.</p><p>The creator of the ESP32, Espressif, has made the <a href="https://github.com/espressif/esptool">esptool</a> which is the most common way to interact with an ESP32. The esptool is a Command Line Interface (CLI) written in Python that gives access to a lot of advanced low-level features such as reading, writing, and erasing specific sections of the flash. The tool is the recommended way to flash an ESP32 but the process is very complex, requiring several commands. We wanted to make the initial flash simple and easy to work with for our users.</p><p>To improve the initial flash experience, we made the Toit CLI wrap the esptool. The toit serial provision command erases, flashes, and reboots the ESP32, making the Toit provisioning a lot simpler. The provision command is even interactive and helps the user through the entire process step by step.</p><p>However, the CLI did not solve the problems for everyone. Some developers prefer working with a GUI and some would even get stuck behind the hurdle of using the terminal and never enter the land of Toit.</p><p>Therefore when the Google Chrome team announced <a href="https://developer.chrome.com/blog/new-in-chrome-89/">Chrome 89</a> with the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API">WebSerial API</a> feature enabled by default, we, at Toit, saw an opportunity to make the initial provisioning even simpler — happy days! The WebSerial API made it possible for us to move the serial interaction from the CLI into a modern OS-agnostic web UI with no additional installation required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tDVexK1R1KS9afM9Iy1MUA.png" /><figcaption>A vacuum cleaner being provisioned with a browser.</figcaption></figure><p>In order to use the WebSerial API to communicate with the ESP32, we had to find a substitute for the esptool that could run in the browser.</p><h3>Esptool ported to JavaScript</h3><p>Early in our efforts to find a browser version of the esptool, we found a project by <a href="https://github.com/adafruit/Adafruit_WebSerial_ESPTool/">Adafruit that ported the esptool to JavaScript</a>. This seemed just the thing we needed. However, their implementation was done as an application rather than a library without good abstractions between DOM manipulations and application logic, which made it hard for us to reuse.</p><p>Unable to find a suitable library, we decided to write one ourselves and open source it: <a href="https://github.com/toitware/esptool.js">github.com/toitware/esptool.js</a>. Our implementation is written in TypeScript and distributed to <a href="https://www.npmjs.com/package/@toit/esptool.js">npm</a> to make it easy to contribute and use. The new serial UI in the Toit console uses the library to flash directly from the browser, as you can see in the demo video here:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZsD59Tg2oCQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZsD59Tg2oCQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZsD59Tg2oCQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddb20d9c7e3d5b960b89fa9ba3897c92/href">https://medium.com/media/ddb20d9c7e3d5b960b89fa9ba3897c92/href</a></iframe><p>During the development of the esptool.js library, we encountered a few challenges. One of them was to adjust the <a href="https://learn.sparkfun.com/tutorials/serial-communication/all#rules-of-serial">baud rate</a> while still communicating with the device. The Python esptool uses a low baud rate to install a bootloader stub onto the ESP32 which afterward can be used to increase the baud rate to speed up flashing. Unfortunately, the WebSerial API only allows you to specify the baud rate when you initially open the port.</p><p>After a few attempts, we found that it was possible to imitate changing the baud rate on the fly by closing the port and reopening it with a higher baud rate:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b39a9a779eb1c1bbbb6d679509ba52c1/href">https://medium.com/media/b39a9a779eb1c1bbbb6d679509ba52c1/href</a></iframe><p>After we started our efforts in building esptool.js, Espressif released <a href="https://github.com/espressif/esptool-js">a JavaScript port of the esptool</a>. This is awesome, and we would’ve been thrilled to use this. That said, their implementation is still in the early days and, like the Adafruit application, lacks a proper separation between application and library.</p><h3>Try it yourself</h3><p>If you want to try the Serial UI yourself, head over to the <a href="https://console.toit.io/">Toit Console</a>, sign up, connect your ESP32 via a serial connection and flash it with the Toit firmware using the Serial UI.</p><p>Last but not least, I would like to send a big thank you to <a href="https://github.com/makermelissa">Maria Mellisa</a> who is the main author of the initial Adafruit implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eccb1483b9c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-toit-take/flash-your-esp32-from-the-browser-using-web-serial-5eccb1483b9c">Flash your ESP32 from the browser using Web Serial</a> was originally published in <a href="https://medium.com/the-toit-take">The Toit Take</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>