[STM32F411E-DISCO] Giroscope and accelerometer in STM32F411E-DISCO

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
ales.coppelli
Posts: 34
Joined: Wed Aug 08, 2018 9:15 am

[STM32F411E-DISCO] Giroscope and accelerometer in STM32F411E-DISCO

Post by ales.coppelli » Sat Sep 15, 2018 6:19 pm

Hi to all.

I have installed latest MiicroPython in STM32F411E-DISCO board.

Are there classes for handle giroscope and/or accelerometer ?

I trayed

>>> dir(machine) and dir(pyb)

but I don't saw any class 'giro' and/or 'accel'.

Someone can help me ?

Thanks

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: [STM32F411E-DISCO] Giroscope and accelerometer in STM32F411E-DISCO

Post by jickster » Sat Sep 15, 2018 6:55 pm

ales.coppelli wrote:Hi to all.

I have installed latest MiicroPython in STM32F411E-DISCO board.

Are there classes for handle giroscope and/or accelerometer ?

I trayed

>>> dir(machine) and dir(pyb)

but I don't saw any class 'giro' and/or 'accel'.

Someone can help me ?

Thanks
The only mention of gyro is for the zephyr

https://github.com/micropython/micropyt ... gyro&type=

Is that your hw module?


Sent from my iPhone using Tapatalk Pro

ales.coppelli
Posts: 34
Joined: Wed Aug 08, 2018 9:15 am

Re: [STM32F411E-DISCO] Giroscope and accelerometer in STM32F411E-DISCO

Post by ales.coppelli » Sun Sep 16, 2018 9:45 am

Thank you for your answer. No, my hardware is different ( STM32F411-DISCO ). I found in "ports/stm/boards/STM32F4DISCO" the class
STAccel and I put it in 'boot.py' file. When I try

>>> a = STAccell()
I obtain

Traceback error:
Exception: LIS302DL or LIS3DSH accelerometer not present

and... is correct :-) because this sensor is in STM32F4-DISCO but not in STM32F411-DISCO ( in this board there is LSM303DLHC (U5) chip).

Anyone know how to modify the 'STAccel' class for this different accelorometer chip ?

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: [STM32F411E-DISCO] Giroscope and accelerometer in STM32F411E-DISCO

Post by SpotlightKid » Sun Sep 16, 2018 10:53 am

When I tested the staccel.py module on an STM32F4 Discovery module, I had to modify it slightly to make it work, because reading the chip ID via SPI would always fail on the first try. I don't know if that's still the case with an up-to-date MicroPthon version. Here's my version:

https://github.com/SpotlightKid/micropy ... ster/accel

To support a new chip, you could start by adding to the initialization code in the init method around line 58. If the LSM303DLHC is similar to the already supported chips you may only need to set the chip configuration and the sensitivity.

ales.coppelli
Posts: 34
Joined: Wed Aug 08, 2018 9:15 am

Re: [STM32F411E-DISCO] Giroscope and accelerometer in STM32F411E-DISCO

Post by ales.coppelli » Sun Sep 16, 2018 11:16 am

Thanks, I'll try it.

Post Reply