adafruit / Adafruit_CircuitPython_MPU6050

CircuitPython helper library for the MPU6050 6-DoF Accelerometer and Gyroscope
MIT License
40 stars 16 forks source link

MemoryError when loading module #36

Open explody opened 10 months ago

explody commented 10 months ago

Using an Adafruit Metro Express M0, CircuitPython 8.2.8, and MPU boards from Amazon, with or without having an MPU board connected, I get an. immediate memory error upon loading the module:

paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import time
=== import board
=== import digitalio
=== import adafruit_mpu6050
=== 
Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "adafruit_mpu6050.py", line 45, in <module>
  File "adafruit_register/i2c_bits.py", line 25, in <module>
MemoryError: memory allocation failed, allocating 60 bytes
>>>

The boards in question do work if I use C - is the M0 just not beefy enough, maybe?

dhalbert commented 10 months ago

The SAMD21 on the Metro M0 only has 32kB of RAM. This library is probably too big. You could try trimming down the source code to remove things you don't need. Are you loading the .py or the .mpy version? The .mpy version will not require on-board compilation, and that might help. But the SAMD21 boards have issues with larger pieces of code.