0

QTPY and multiple I2C device libraries
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

QTPY and multiple I2C device libraries

by K_tWizel on Sun Jul 18, 2021 1:21 pm

Hey Team
I'm working with a QTPY and the MiniGPS, a BME280, and a LIS3MDL. I have upgraded my QTPY to the 2M memory. I have all the boards connected via STEMMA. I can get the individual boards to test correctly loading the modules and code.

My issue is when attempting to run the code/libraries for the BME280 and the miniGPS, there isn't enough memory for the GPS library to load and I error out of my script. My memory test shows 19k roughly before loading the library (I know there's a difference between the RAM and ROM to run). How much memory is needed to run the miniGPS library and does the QTPY have enough to run all three boards at once?

- KW

K_tWizel
 
Posts: 6
Joined: Wed Nov 30, 2016 3:01 pm

Re: QTPY and multiple I2C device libraries

by dastels on Sun Jul 18, 2021 6:56 pm

This guide is full of tips and techniques for reducing both: https://learn.adafruit.com/Memory-saving-tips-for-CircuitPython

Dave

dastels
 
Posts: 7493
Joined: Tue Oct 20, 2015 3:22 pm

Re: QTPY and multiple I2C device libraries

by K_tWizel on Mon Jul 19, 2021 10:39 am

*** Fix Found for Issue ***
Following the guide provided, I was able to overcome my memory issues with the QTPY.

Specifically:
Created a separate .py file with my code
Copied .py onto QTPY This is key or it won't work (found out the hard way myself)
In the code.py file, ref'd the .py

Example:
My .py file -> Test_GPS.py (saved on QTPY)
The code in my code.py file ->
Code: Select all | TOGGLE FULL SIZE
import Test_GPS.py


I'm available to help, though not an expert.

(I'm using Mu)
Save code.py normally to run on QTPY
Edits can be made to my .py file 'on the fly' which are then loaded by code.py


Ref's:
Section - When to pre-compile your own code
URL - https://learn.adafruit.com/Memory-saving-tips-for-CircuitPython/non-volatile-not-enough-disk-space
NOTE: I did not have to precompile my code as the ref states... just saved file and imported

K_tWizel
 
Posts: 6
Joined: Wed Nov 30, 2016 3:01 pm

Re: QTPY and multiple I2C device libraries

by K_tWizel on Mon Sep 20, 2021 5:50 pm

So... Update...

My last suggestion does work, don't get me wrong. However, I am not able to get all the libraries to load. I have two primary functions:
- GPS (miniGPS)
- Temp/Press/Humid (MS8607)

There doesn't seem to be enough ROM to load these libraries... I get a MemoryError: allocation error 64 bytes.
I've tried "from <library> import <module>" to load only what I need but still get the allocation error.

I'm guessing I didn't spec my Controller big enough as I have more libraries to add.

Suggestions? want to keep the form-factor down but will be adding ADC and APRS libraries

-K-tWizel

K_tWizel wrote:*** Fix Found for Issue ***
Following the guide provided, I was able to overcome my memory issues with the QTPY.

Specifically:
Created a separate .py file with my code
Copied .py onto QTPY This is key or it won't work (found out the hard way myself)
In the code.py file, ref'd the .py

Example:
My .py file -> Test_GPS.py (saved on QTPY)
The code in my code.py file ->
Code: Select all | TOGGLE FULL SIZE
import Test_GPS.py


I'm available to help, though not an expert.

(I'm using Mu)
Save code.py normally to run on QTPY
Edits can be made to my .py file 'on the fly' which are then loaded by code.py


Ref's:
Section - When to pre-compile your own code
URL - https://learn.adafruit.com/Memory-saving-tips-for-CircuitPython/non-volatile-not-enough-disk-space
NOTE: I did not have to precompile my code as the ref states... just saved file and imported

K_tWizel
 
Posts: 6
Joined: Wed Nov 30, 2016 3:01 pm

Re: QTPY and multiple I2C device libraries

by K_tWizel on Mon Sep 20, 2021 5:50 pm

So... Update...

My last suggestion does work, don't get me wrong. However, I am not able to get all the libraries to load. I have two primary functions:
- GPS (miniGPS)
- Temp/Press/Humid (MS8607)

There doesn't seem to be enough ROM to load these libraries... I get a MemoryError: allocation error 64 bytes.
I've tried "from <library> import <module>" to load only what I need but still get the allocation error.

I'm guessing I didn't spec my Controller big enough as I have more libraries to add.

Suggestions? want to keep the form-factor down but will be adding ADC and APRS libraries

-K-tWizel

K_tWizel wrote:*** Fix Found for Issue ***
Following the guide provided, I was able to overcome my memory issues with the QTPY.

Specifically:
Created a separate .py file with my code
Copied .py onto QTPY This is key or it won't work (found out the hard way myself)
In the code.py file, ref'd the .py

Example:
My .py file -> Test_GPS.py (saved on QTPY)
The code in my code.py file ->
Code: Select all | TOGGLE FULL SIZE
import Test_GPS.py


I'm available to help, though not an expert.

(I'm using Mu)
Save code.py normally to run on QTPY
Edits can be made to my .py file 'on the fly' which are then loaded by code.py


Ref's:
Section - When to pre-compile your own code
URL - https://learn.adafruit.com/Memory-saving-tips-for-CircuitPython/non-volatile-not-enough-disk-space
NOTE: I did not have to precompile my code as the ref states... just saved file and imported

K_tWizel
 
Posts: 6
Joined: Wed Nov 30, 2016 3:01 pm

Re: QTPY and multiple I2C device libraries

by franklin97355 on Mon Sep 20, 2021 6:10 pm

i'M NEW TO PYTHON BUT THE MPY VERSIONS ARE SMALLER THAN REGULAR PY FILES AND THERE IS A TUTORIAL ON CREATING THEM. (sorry about the yelling, fat fingers)

franklin97355
 
Posts: 22244
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: QTPY and multiple I2C device libraries

by K_tWizel on Tue Sep 21, 2021 10:44 am

franklin97355 wrote:i'M NEW TO PYTHON BUT THE MPY VERSIONS ARE SMALLER THAN REGULAR PY FILES AND THERE IS A TUTORIAL ON CREATING THEM. (sorry about the yelling, fat fingers)



Yeah... I may have to look into rolling my own library for this. Wasn't in the plan but you know... flexibility. Also may just upgrade my controller to something that has enough ROM and keep the QTPy for something else... maybe a digital compass as I have an LIS board... throw in one of the 3-color e-ink screens

K_tWizel
 
Posts: 6
Joined: Wed Nov 30, 2016 3:01 pm

Please be positive and constructive with your questions and comments.