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 beta branch of 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.


Setup

  1. Using Windows 8+, Mac or Linux
  2. Open this article in  Google Chrome v 65+ or another Chrome based browser and download the latest version of DAPLink.
  3. Update the firmware on your micro:bit by following our usual instructions for performing a firmware update, replacing eg 0243 with the latest release. If the update is successful, you should see 'WebUSB' listed in the supported protocols of the DETAILS.TXT on the MICROBIT drive.

    # DAPLink Firmware - see https://mbed.com/daplink
    Unique ID: 9901000049624e45005b400f000000250000000097969901
    HIC ID: 97969901
    Auto Reset: 1
    Automation allowed: 0
    Overflow detection: 0
    Daplink Mode: Interface
    Interface Version: 0253
    Bootloader Version: 0246
    Git SHA: 682d8303e37355532402b8d93c4f240a3cec02a9
    Local Mods: 0
    USB Interfaces: MSD, CDC, HID, WebUSB
    Bootloader CRC: 0xf9d354f5
    Interface CRC: 0x3f2b7e12
    Remount count: 0
    URL: https://microbit.org/device/?id=9901&v=0253


  4. Your micro:bit is now ready to test with WebUSB. 


If you experience a device not found issue on Windows, check that the mBed driver is installed properly.


Testing Web USB in MakeCode

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


Testing 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


Testing Web USB in the Python Editor

  1. In a Chrome based browser, open https://python.microbit.org/v/beta which is a beta instance of the python editor with Web USB enabled. 
  2. The main menu should contain an additional menu item entitled Connect, choose this 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.

Testing the REPL with webUSB in the Python Editor

We have also introduced a REPL (Read-Eval-Print-Loop) shell function in the beta 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 in the beta you must reload the browser after using the REPL before flashing with webUSB.


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.