Microbit - Extension that adds to the simulator (and debugger)

I would like to add a console to the simulator. It would be nice if it was available in the debugger as well. A general instruction on how to create an extension that adds to the simulator would be great. I could then add other items (like an FRAM module that I’ve been using in my classroom).

@mwest226 Do you mean something different than the Serial Console? It can be used for a lot of debugging and status messages (as well as data communication).

If you’re not sure what I mean, here’s a pretty good video overview:
https://www.youtube.com/watch?v=b-8LOxIlPkI .
It shows data logging and a graph first, but also shows more traditional console messages that could be used for debugging here: https://www.youtube.com/watch?v=b-8LOxIlPkI&t=580s (Specifically mentions “This is really useful for debugging:slight_smile: )

Sorry, I should have been clearer. I am using javascript and I would like to be able to read from the serial.

It may not be what you’re looking for, but the Serial blocks are ok in JavaScript and a good alternative to console.log(). (It’s pretty common in embedded systems like the micro:bit to use the serial output for console/debugging needs).

In fact, you could just create a console.log() that just calls the serial methods:

class console {
    log(v: string) {

basic.forever(function () {

Sorry, I think you misunderstand. I would like a box in the simulator where the user can enter text. The serial.readline would be able to get the text and the user could run their code which uses the serial to read and write. They could also debug their program. I don’t think the console object in chrome has a way to get user input.

@mwest226 Yes, I did misunderstand!

You may want to create a “issue” on the GitHub repository to request this feature: https://github.com/microsoft/pxt-microbit/issues .

Since you know JavaScript, you could create your own console webpage with an input box. I have a library that could make it a bit easier to do the communication with the micro:bit. Here’s a demo page: https://bsiever.github.io/microbit-webusb/

  • The demo page only sends “Test” to all connected micro:bits. You could make your own version with a text field to enter values.
  • I created it to simplify work for data graphing applications. People who have not needed graphing have just removed some lines of code that parse out graph data (anything with a : is assumed to be graph data). I think removing lines 28-47 of ubitwebusb.js will do it.
  • I think only one browser page can use the USB connection at a time. In order to use it you may have to disconnect the MakeCode tab (or close it) and vice versa.

Here’s the GitHub repo with the code, including the example index.html: https://github.com/bsiever/microbit-webusb

Thank you for the suggestions. I’ve created a request on the issues page you mentioned. I have a page already setup to allow my students to interact with the microbit over serial, but it does not have the debugger. The debugger is a important feature that I was hoping to make available for the whole course. I will continue to look for a good tutorial on extension creation. I feel that the documentation available is not helpful.