Microbit version 2 error with grove inventor kit

Hi there

I received the new microbits about a week ago. I’ve just had a chance to play with them and have found an error in working with the Grove inventor kit and microbits.

This code:

display: grove.TM1637 = None

distance = 0

def on_forever():

    global display, distance

    display = grove.create_display(DigitalPin.P1, DigitalPin.P15)

    distance = grove.measure_in_centimeters(DigitalPin.P2)






Drop the above code into makecode for microbit - the python tab

Then you can click blockcode to make it easier to understand if you like.

The code repeatedly takes the value from the ultrasonic sensor (pin 2 ) and prints out on the 4 digit screen (pin 1) the distance reported.

In short, it works fine with the microbit version 1. With the version 2 it fails and reports a 020 error on the microbit.

Could be just me. Give it go if you have the gear and let me know if you have more success.


Hi Shaby,

A quick tip for sharing micro:bit code, you can use the share button to create a unique URL to your project:

We don’t currently have any of the Grove inventor kits in stock, so I can’t test it here, however, I’ve been doing some digging and a few things to check:

Which Grove connector are you using? The Seeed Studio example for this code use the P0/P14 Grove connector, not the P2/P16 Grove connector (although it shouldn’t make a difference).

Have you tried rounding the measured value? I note that distance is a float, so it’s quite a long number to display which may be the cause of the 020 out of memory error (although I’d think the Grove code should be setup to round it before outputting to the display).


Hi Oli

I just sent the issue through using a reply to email that Graham sent out to customers just 15 minutes ago. I’ve tried it on p0 as well and it does not work. I deliberately didn’t use p0 as I wanted an alarm sound and on the v1 microbits p0 is used for sound. Tried it on p2 and it didn’t work either.

The 4 digit display does not show a float – it displays just integers, so 535 in the case of this program shows a distance of 535 cm or 5.35 metres, but it won’t show the decimal, even if you add the math code (/100).

This is an interesting error and one which LOTS of teachers will ask me about as they get new microbits v2. As I stated, I’ve only ust started playing with this new version of the microbit, so am expecting a whole bunch of errors now as I code for both versions. Cound it have anything to do with the universal hex thingy that they created for this version?


I know BBC went to great lengths to make the v2 fully backwards compatible with the V1, but since the V2 uses different hardware behind the curtain there’s a lot of work going on to achieve this. It’s hard to say exactly - and it’s odd that the out of memory occurs on the V2 and not the other way around. That would at least make more sense since the V2 is much more powerful hardware.

Definitely seems like it might be an overflow of some type.

Probably worth submitting a ticket to: https://support.microbit.org/support/home