# ESP32 Bin Uploader

**File:** `ESP32-Bin-uploader.html`

A tool that flashes a `.bin` firmware file straight from the browser onto an ESP32 or
Arduino Nano ESP32, using the **Web Serial API** and Espressif's official `esptool-js`
library — the same protocol as the `esptool.py` command-line tool, entirely in the browser.

This is a single, self-contained HTML file: no installation required, just open it in a browser.

> No download, no `.bat` file, no Arduino IDE or `arduino-cli` needed. Everything happens on the page itself.

## Requirements

- Google Chrome or Microsoft Edge (desktop) — Web Serial is not supported by Firefox or Safari.
- An active internet connection the first time, to load the `esptool-js` library.

## Usage

1. Open `ESP32-Bin-uploader.html` in Chrome or Edge.
2. Click **Verbind met apparaat** (Connect device) and pick the board's COM port in the system dialog.
3. Drag the `.bin` file into the drop zone, or browse to select it.
4. Click **Upload Firmware** and wait for the progress bar to finish.

The tool always flashes at address `0x10000` — the standard offset for a plain compiled
Arduino sketch file (`....ino.bin`).

## The COM port changes while connecting (Arduino Nano ESP32 and similar)

This board identifies itself as **two different USB devices** depending on its mode —
normal mode and bootloader mode each have their own VID/PID pair, and therefore their
own COM port (e.g. COM6 → COM5). Web Serial — the browser security model this tool relies
on — requires an explicit, manual click from you for every new USB device it hasn't seen
before. No web page can bypass that automatically; this isn't a bug in the tool but a
property of the board combined with how browsers handle USB permissions (Arduino's own
tooling occasionally runs into the same thing).

This is expected, and the workflow is simple:

1. Click **Verbind met apparaat** (Connect device) and pick the first COM port (e.g. COM6).
2. This fails with a message — that's expected, the board has now switched to bootloader mode.
3. Click **Verbind met apparaat** again and pick the new port now listed (e.g. COM5, often named "USB JTAG/serial debug unit").
4. This second attempt succeeds and you can upload.

## The board doesn't restart on its own after uploading

After flashing, the tool automatically tries to restart the board with a
**watchdog reset** — this works on most ESP32 variants. On some native-USB boards
(such as the Arduino Nano ESP32) this isn't always reliable — a known limitation of
that board, present in Arduino's own upload tooling too. If the board doesn't boot on
its own, just press **RESET** once.

## Tips

- Make sure no other program (Arduino IDE, a serial monitor, the BLE terminal) already has the board's COM port open.
- Some boards need to be put into flash mode manually: hold the **BOOT** button while connecting.
- If the board doesn't show up at all, check that the correct driver is installed (CH340 / CP210x / FTDI).

## Author

EdSoft — [github.com/ednieuw/HTML-BLEserial](https://github.com/ednieuw/HTML-BLEserial)
