The Web USB API facilitates communicating with USB devices from the Browser. The API is currently available in Chrome and is supported in beta releases of the Javascript Block Editor and the Python Editor in Chrome v65+. 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+ (other browsers do not yet have Web USB support) and download the latest version of DAPLink (0250) attached to the bottom of the article, 
  3. Update the firmware on your micro:bit to 0250 by following our usual instructions for performing a firmware update, replacing 0243 with 0250. 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: 0250
    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=0250


  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 the Javascript Blocks Editor

  1. Open https://makecode.microbit.org/beta#editor which is a beta instance of the makecode editor with Web USB enabled. 
  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 the Python Editor

  1. 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 Flash, choose this and follow the browser instructions to select your device and connect. Once the device is paired the process of flashing will begin and once the device is flashed you will be returned to the editor.


  3. In the current configuration you will be asked to choose a device every time you select 'Flash'. 
  4. 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. Remove the code from the code window and flash the empty program to the micro:bit.
  2. Choose the REPL button to open the shell and follow the prompts to connect.

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


Troubleshooting and Further Information


As the beta testing progresses, we will add troubleshooting information regarding webUSB to this section