Example of WebUSB being used by Browser Based App to communicate with a Microbit

Our STEM club has a couple of projects in mind that required a Browser based App (HTML/javascript etc) to communicate serially with a Microbit.

Microbit help/support suggests using webUSB as a channel - using (I assume) WebUSB serial.js

However I’ve not succeeded in finding any working examples to learn from.

Can anyone point us in a useful direction?

Thanks in advance

1 Like

Hi @broadside & welcome to the forum,

I created a WebUSB library for the micro:bit that a few others have used. It was really meant for graphing applications and treats messages with a colon, like “x:5”, specially.

You’re welcome to use it or review the code for inspiration: https://github.com/bsiever/microbit-webusb. The repository includes a working example of a basic console and docs:

Originally it was a stand alone library. Unfortunately, the micro:bit v2.2 boards weren’t compatible, so I decided to make it a wrapper around DAPjs (using DAPjs seemed more robust).

2 Likes

You beat me to it!!! I just came here to point everyone to your Github page! I found your page earlier, and had it working in minutes.

Thank you very much for documenting this, and the work you put into it

It works really well for what we have in mind - and a great starting point for our next projects (the first is connecting to an RFID reader/writer, the second is to implement a better controller for lighting a very large model of a future Mars colony!!)

Ken

@broadside Great — I’m happy to hear people are finding it useful! Feel free to let me know if you have any questions. I know some users have removed the part that parses the key/value pairs used for graphing because it wasn’t suitable for their purposes.

If you have a chance, please post details of your work here when you’re done. It sounds like a fun project. I sometimes teach IoT topics, including integrating with things like RFID readers. I enjoy seeing those sorts of projects.

Bill