Page 1 of 1

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

Posted: Sat Sep 29, 2018 1:21 pm
by gorbak
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!!

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

Posted: Sat Sep 29, 2018 2:04 pm
by shaoziyang
You need micropython 1.9.2 for microbit to use i2c.scan(). Mu 1.0 using micropython 1.9.2.

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

Posted: Sat Sep 29, 2018 6:23 pm
by gorbak
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?

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

Posted: Sat Sep 29, 2018 7:44 pm
by deshipu
I think you can get it from https://github.com/mu-editor/mu/releases