The Web USB API facilitates communicating with USB devices from the Browser. The API is currently available in Chrome based browsers 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.


Requirements

To use WebUSB, you'll need to have:


Web USB in MakeCode

  1. Open https://makecode.microbit.org
  2. 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.


  3. 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. 
  4. For issues with MakeCode and webUSB, please open a support ticket or if you are comfortable using Github, file an issue onthe PXT repository.


Web USB in the Python Editor

  1. In a Chrome based browser, open https://python.microbit.org/
  2. Choose Connect from the menu and follow the browser instructions to select your device and Connect. Once the device is paired, the Download button becomes Flash, pressing this will begin the process of flashing the micro:bit.

  3. For problems with the Python Editor and webUSB, please raise a support ticket or if you are comfortable using Github, file an issue on the Python editor repository.

Using the REPL with webUSB in the Python Editor

We have also introduced a REPL (Read-Eval-Print-Loop) shell function in the editor.

  1. 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.

  2. 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.


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



  1. Plug in your cable and open https://makecode.microbit.org#editor.
  2. 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.
  3. 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.
  4. For issues with MakeCode and webUSB, please open a support ticket or if you are comfortable using Github, file an issue onthe PXT repository.


If you see the message "Corrupted MBED USB drive", perform a firmware update



For problems with the Python Editor and webUSB, please raise a support ticket or if you are comfortable using Github, file an issue on  the Python Editor repository.


Due to a technical limitation in the software you may experience data loss if you are sending data over serial at a high rate.


Troubleshooting

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.