The WebUSB API facilitates communicating with USB devices from the Browser. The API is currently available in Chrome based browsers (Android, Chrome OS, Linux, macOS and Windows)and is supported in the MakeCode Editor and the Python Editor. This enables you to flash your micro:bit straight from the browser without the need to save the .hex file first, and use serial communication between the micro:bit and the editor. WebUSB is still in development, so your feedback on it is most welcome.
To use WebUSB, you'll need to have:
- Windows 8+, Mac, Chrome OS, Android or Linux as your operating system.
- A Chrome based browser like Google Chrome at version 65 or above or Microsoft Edge
- micro:bit firmware at version 0243 or above
Web USB in MakeCode
- Select the more options (three dots) menu next to the Download button and then choose Pair Device.
- A browser pop-up will let you select your BBC micro:bit and then click Connect. You will see the USB symbol flashing on the Download button to indicate a successful connection.
- Select Download to instantly flash your program to the micro:bit. The first time you do this it may take a bit longer, but subsequent flashes will be faster.
Web USB in the Python Editor
- Choose Connect from the menu. A browser pop-up will let you select your BBC micro:bit and then click Connect. Once the device is paired, the Download button becomes Flash.
- Select Flash to instantly flash your program to the micro:bit. The first time you do this it may take a bit longer, but subsequent flashes will be faster.
Using the REPL with webUSB in the Python Editor
We have also introduced a REPL (Read-Eval-Print-Loop) shell function in the editor.
- With a micro:bit that has been connected over USB and flashed with a Python program, select the Open Serial button. Click the banner or press CTRL-C to enter the REPL.
You can now communicate with the micro:bit as if you have a serial connection.
Note that you must reload the browser after using the REPL before flashing with webUSB.
Due to a technical limitation in the software you may experience data loss if you are sending data over serial at a high rate.
Web USB in MakeCode on Android with a USB OTG cable
For this to work you will need to use a USB On-the-Go cable
- Plug in your cable and open https://makecode.microbit.org#editor.
- The settings menu in MakeCode should contain an additional menu item entitled Pair Device, select this and follow the browser instructions to select your device and connect.You will see a notification in makecode that your device is paired and asking you to try downloading now.
- Try Downloading! You should see that the micro:bit being flashed instantly. The first time you do this, it may take a bit longer, but subsequent flashes should be faster than when using drag-and-drop.
If you see the message "Corrupted MBED USB drive", perform a firmware update
WebUSB is still in development and as such you may experience issues in using it. Here is some troubleshooting advice for using webUSB with the micro:bit and the editors.