[Microbit-Python] microbit accelerometer

Damien George damien.p.george at gmail.com
Tue May 3 07:27:50 EDT 2016


Thanks Carlos!  Please see https://github.com/bbcmicrobit/micropython/issues/264

On Tue, May 3, 2016 at 12:16 PM, Carlos P.A. <carlos.p.a.87 at gmail.com> wrote:
> If that's basically exposing the MicroBitAccelerometer::setRange function in
> Micropython (I'm assuming the updateSample already takes in consideration
> the selected range) I'd be happy to have a look tonight and submit a PR.
>
> On 3 May 2016 at 11:57, Damien George <damien.p.george at gmail.com> wrote:
>>
>> Hi Simon,
>>
>> It is possible, just depends how easy it is to do!
>>
>> There is an underlying configuration option to set the range, but
>> MicroPython does not expose that function.  We should probably do
>> that, then you could do something like: accelerometer.set_range(8).
>>
>> Alternatively you can use the I2C bus to send values to the
>> accelerometer to change its range.  It's actually pretty easy and you
>> can do it right now with this code:
>>
>> i2c.write(0x1d, b'\x2a\x00') # disable device
>> i2c.write(0x1d, b'\x0e\x02') # set range to 8g
>> i2c.write(0x1d, b'\x2a\x21') # enable device, sample rate of 50Hz
>>
>> Note that the numbers coming from get_x() etc will now be 4 times
>> smaller. 240 is around 1g, but you can now get to 2000 which is 8g.
>>
>> Cheers,
>> Damien.
>>
>>
>>
>> On Mon, May 2, 2016 at 5:34 PM, Simon Fitzjohn
>> <simon.fitzjohn at btopenworld.com> wrote:
>> > Hi All,
>> >
>> >
>> >
>> > Is there any way of changing the sensitivity on the accelerometer. Have
>> > checked MMA8652 specs and appreciate that it defaults to +/- 2g but
>> > would
>> > like to change range to +/- 8g so as to use it with Physics type impact
>> > investigations.
>> >
>> >
>> >
>> > Even a confirmation that it is not currently possible would be helpful .
>> > . .
>> > but note that an 8g gesture is part of microbit module!
>> >
>> >
>> >
>> > Many thanks,
>> >
>> >
>> >
>> > Simon
>> >
>> >
>> > _______________________________________________
>> > Microbit mailing list
>> > Microbit at python.org
>> > https://mail.python.org/mailman/listinfo/microbit
>> >
>> _______________________________________________
>> Microbit mailing list
>> Microbit at python.org
>> https://mail.python.org/mailman/listinfo/microbit
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>


More information about the Microbit mailing list