AttributeError: 'MicroBitI2C' object has no attribute 'scan'

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
gorbak
Posts: 2
Joined: Sat Sep 29, 2018 1:09 pm

AttributeError: 'MicroBitI2C' object has no attribute 'scan'

Post by gorbak » Sat Sep 29, 2018 1:21 pm

I'm just trying to get started with i2c on the micro:bit. I'm using Mu and have entered this simple program...

from microbit import *
print(i2c.scan())

And I'm getting this error....

Traceback (most recent call last):
File "__main__", line 3, in <module>
AttributeError: 'MicroBitI2C' object has no attribute 'scan'
MicroPython v1.7-9-gbe020eb on 2016-04-18; micro:bit with nRF51822
Type "help()" for more information.
>>>

Help please!!

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: AttributeError: 'MicroBitI2C' object has no attribute 'scan'

Post by shaoziyang » Sat Sep 29, 2018 2:04 pm

You need micropython 1.9.2 for microbit to use i2c.scan(). Mu 1.0 using micropython 1.9.2.

gorbak
Posts: 2
Joined: Sat Sep 29, 2018 1:09 pm

Re: AttributeError: 'MicroBitI2C' object has no attribute 'scan'

Post by gorbak » Sat Sep 29, 2018 6:23 pm

Cool. And thanks so much for the quick reply. I see lots of references to micropython 1.9.2, so I suspected that might be the case.

So, presumably the docs on https://microbit-micropython.readthedocs.io/en/latest/ cover micropython v1.9.2 (or something similar) for microbit.

But https://codewith.mu/en/download has a version of Mu (for Mac OS X at least) that is based on (or defaults to using?) micropython v1.7.9.

So how do I set Mu to used micropython 1.9.2, or do I need to download a different version of Mu from somewhere else? This seems like really basic stuff, so I wonder how beginners are meant to work this out for themselves?

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: AttributeError: 'MicroBitI2C' object has no attribute 'scan'

Post by deshipu » Sat Sep 29, 2018 7:44 pm

I think you can get it from https://github.com/mu-editor/mu/releases

Post Reply