Gemma M0 code not persisting?

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
masonmontero
 
Posts: 9
Joined: Mon Nov 22, 2021 7:08 pm

Gemma M0 code not persisting?

Post by masonmontero »

I just bought a Gemma M0 and am having some problems with the test program running when it's not connected to my computer.

The basic code that displays a rainbow of LED colors was already loaded in the code.py file on the Gemma runs perfectly while I've got the Gemma connected to my computer through a USB cord. But if I disconnect the Gemma, plug it into an external LiP04 battery, and turn it off then back on, the Gemma starts to behave like it's waiting for a program to run? Meaning, it shows the green LED for a second, then a flashing yellow and blue LED.

I would expect the Gemma to still be able to run that basic program when I've got it connected to an external battery source and no longer connected to my laptop. Do I need to move the code.py file into a specific folder for that to happen?

This is my first time playing around with a micro-controller and CircuitPy so I'm sure I'm just making some sort of beginners mistake.

Thanks for any and all help!

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: Gemma M0 code not persisting?

Post by adafruit_support_carter »

What you describe seems fine. The LED behavior here:
Meaning, it shows the green LED for a second, then a flashing yellow and blue LED.
sounds like it might be blinking an error code. Here's the decoder ring:
https://learn.adafruit.com/welcome-to-c ... 2978455-19

Which LiPo battery are you using? Is it fully charged?

User avatar
masonmontero
 
Posts: 9
Joined: Mon Nov 22, 2021 7:08 pm

Re: Gemma M0 code not persisting?

Post by masonmontero »

Thanks for the help! Unfortunately, I wasn't able to figure out what the color sequence means when it's not connected to my laptop anymore?

Here's how the microcontroller runs when it's connected to my laptop via a USB: https://youtu.be/jEqNrvSlA9o

And this is the color/blinking pattern (Solid Green -> Solid Yellow -> Blinking Yellow -> Blinking Blue) when it's running solely on the battery: https://youtu.be/onGAFhu8KgU

The battery is also from Adafruit: Lithium Ion Polymer Battery - 3.7v 150mAh https://www.adafruit.com/product/1317

User avatar
masonmontero
 
Posts: 9
Joined: Mon Nov 22, 2021 7:08 pm

Re: Gemma M0 code not persisting?

Post by masonmontero »

Sorry, I just realized I was using the wrong terms in describing the issue. It's the "DotStar" that's showing Solid Green -> Solid Yellow -> Blinking Yellow -> Blinking Blue

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: Gemma M0 code not persisting?

Post by adafruit_support_carter »

It looks like you are running a pre 7.x version of CircuitPython. So the status RGB is indicating:

* steady green = code.py is running
* steady yellow = other error
* 3 yellow blinks + 4 blue blinks = line 430

What is the code.py you are running? Can you link to it?

User avatar
masonmontero
 
Posts: 9
Joined: Mon Nov 22, 2021 7:08 pm

Re: Gemma M0 code not persisting?

Post by masonmontero »

hmmm... the code.py doesn't have a line 430?

Here's a Github gist of that code: https://gist.github.com/adamcasey28/f1d ... 87f1cda423

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: Gemma M0 code not persisting?

Post by adafruit_support_carter »

Was wondering about that. Did seem like a high line number. OK, let's try a simpler example. Just to see if we can *something* working on battery. Try changing your code.py to this simple blink example:

Code: Select all

import time
import board
import adafruit_dotstar as dotstar

dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)

while True:
    dot.fill(0xADAF00)
    time.sleep(0.5)
    dot.fill(0)
    time.sleep(0.5)

User avatar
masonmontero
 
Posts: 9
Joined: Mon Nov 22, 2021 7:08 pm

Re: Gemma M0 code not persisting?

Post by masonmontero »

I'm not sure what I did but somehow I'm getting the expected behavior from the Gemma when connected to the Lithium battery and it's powered on/off :) :)

I'll have to open a new forum post because now I'm having issues importing the "pwmio" module for this LED masquerade mask project: https://learn.adafruit.com/led-masquera ... ctive-mask

When I "check" the code in my Mu IDE by running the "serial" option, it's giving me an import error?

Thanks for the help!!

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: Gemma M0 code not persisting?

Post by adafruit_support_carter »

There could be potential brown out or other marginal power issues happening when operating on the LiPo. Maybe it wasn't fully charged?

User avatar
masonmontero
 
Posts: 9
Joined: Mon Nov 22, 2021 7:08 pm

Re: Gemma M0 code not persisting?

Post by masonmontero »

That very well could've been it because I did charge the lithium battery while trying to debug all of this

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: Gemma M0 code not persisting?

Post by adafruit_support_carter »

OK, make sure the battery is fully charged and try again. If the behavior seems to repeat with a good battery charge, we can continue to investigate. But weird behavior can happen when the battery voltage gets low. It's not as simple as working....working....working...not working. It's more like working...working....working....working...weird behavior.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”