0

[SOLVED} Trinket M0 only boots via USB power
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

[SOLVED} Trinket M0 only boots via USB power

by WidescreenJohn on Wed Jun 12, 2019 6:29 pm

I'm attempting to create my own animated LED strip based on the configuration of the Zelda Guardian Sword; however, it looks like the Tinker M0 is only booting when the USB cable is plugged in. It will not run when it's only on battery, even though some of the Tinker's LED still light up.

Parts:
- Trinket M0
- Neo Pixel mini strip
- LiPo backpack
- Slide switch
- PkCell 2000mAh 3.7V battery (not the cylindrical 2200 mAh battery that goes with the Guardian sword)

The wires are connected as such in reference to my photos:
- Green (battery) - Trinket M0 Bat, backpack Bat, + on NeoPixel (arrow side)
- Red (ground) - Trinket M0 Gnd, backpack G, - on NeoPixel (arrow side)
- Blue (data) - Trinket M0 4, D on NeoPixel (arrow side)
- Black (USB) - Trinket M0 USB, backpack 5V
- Slide switch - backpack switch connectors

Because I'm not doing anything at the moment except testing the circuitry, I'm using the default code that is on the Trinket; however, I added the latest neopixel.mpy to the M0's /lib directory.

When the USB is plugged in, all three of the Trinket M0's LEDs turn on, the RGB LED in the center starts to change colors, and the LiPo battery LED is active on the backpack. RIght now the battery is fully charged. If I turn the switch on, the NeoPixel LED turns on and changes colors. If I turn the switch off, the NeoPixel LED turns off. From that perspective, everything appears to be working as it should.

However, when I unplug the USB port and turn the switch on, the M0's power LED turns on, the M0's LED #13 quickly flashes then turns off, the M0's RGB LED stays static, and nothing happens on the NeoPixel. There are no lights on the backpack. Meanwhile, turn the switch off, plug the USB back in, everything comes up; hit the switch and the NeoPixel starts changing colors.

I've used my multimeter to verify that there are no shorts and that the end-to-end connections are good, including connectivity test using the underside connections, but I'm still a bit of a n00b so I'm worried that the backpack might have gotten damaged from the soldering. Unless there is something about running on battery that I'm missing, I can't figure out what's up. My Guardian Sword, however, is working like a champ and received a ton of praise on Halloween last year.

I've attached pictures and they're not fantastic, but they can at least show what I'm talking about. If you're confused about why the wires don't look like they're soldered to the boards, well, they're no really. I soldered the posts onto the board thinking that it would be easier for my project. Any direction on where to look to troubleshoot this would be very welcome.

** UPDATE **

I monitored the USB port in the Arduino console and I noticed that there was something registering on D3 when there shouldn't be. I cleaned off that area and noticed that not only did D3 stop registering but LED 13 went out. So something must have establishing a connection, though I'm not sure what.

Here's the part that's getting me. If the USB cable is plugged in and I turn the switch on to get the NeoPixel LED activated, I can then unplug the USB port and it will stay active, changing colors like I would expect. When I turn the switch off and turn it back on again, it's back to not turning on the LED and the DotStar LED is static. So it's not booting up when it's on the battery. Is the Trinket set up by default to only boot if it detects an active USB connection?
Attachments
IMG_20190612_172934A.jpg
USB plugged in
IMG_20190612_172934A.jpg (268.67 KiB) Viewed 128 times
IMG_20190612_172859A.jpg
Running on battery
IMG_20190612_172859A.jpg (237.45 KiB) Viewed 128 times
Last edited by WidescreenJohn on Thu Jun 13, 2019 6:28 pm, edited 1 time in total.

WidescreenJohn
 
Posts: 9
Joined: Wed Apr 25, 2018 12:03 am

Re: Trinket M0 only boots via USB power

by adafruit_support_carter on Thu Jun 13, 2019 1:10 pm

Do you have a line like this in your setup()?
Code: Select all | TOGGLE FULL SIZE
while (!Serial);

adafruit_support_carter
 
Posts: 12039
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trinket M0 only boots via USB power

by WidescreenJohn on Thu Jun 13, 2019 2:49 pm

No. I'm still using the default Trinket IO demo main.py that comes with the Trinket M0 and the main loop is
Code: Select all | TOGGLE FULL SIZE
while True:
.

WidescreenJohn
 
Posts: 9
Joined: Wed Apr 25, 2018 12:03 am

Re: Trinket M0 only boots via USB power

by adafruit_support_carter on Thu Jun 13, 2019 3:31 pm

Oh, this is in CircuitPython.

Hmm. Try changing your code.py to a simple blink sketch and see if that will run off battery:
Code: Select all | TOGGLE FULL SIZE
import time
import board
from digitalio import DigitalInOut, Direction

led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

while True:
    led.value = not led.value
    time.sleep(0.2)

adafruit_support_carter
 
Posts: 12039
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trinket M0 only boots via USB power

by WidescreenJohn on Thu Jun 13, 2019 6:27 pm

Beautiful! That worked great on battery. Afterwards, I put in the code for the Guardian Sword (which I suppose I should have tried in the first place) and the NeoPixel lit up exactly as it's supposed to while on battery. So it looks like there is something about the default Tinker M0 main.py that doesn't like running while connected to a battery. I'm still a n00b when it comes to this sort of thing or I'd look further into it.

I've been writing scripts for UNIX servers for 25 years but a little Tinker M0 brought me to my knees. XD It's all good, though. You have to start somewhere.

Thanks for your help! I plan on using this setup for cosplay weapons that I've started designing, so I'll make sure to not stick with the default main.py for initial testing, at least for now.

WidescreenJohn
 
Posts: 9
Joined: Wed Apr 25, 2018 12:03 am

Re: [SOLVED} Trinket M0 only boots via USB power

by adafruit_support_carter on Thu Jun 13, 2019 7:12 pm

Cool. Glad you got it working. One other gotcha to watch out for is having multiple files with these names:
https://learn.adafruit.com/welcome-to-c ... -file-7-32
Like if you have a code.py you forgot all about and are wondering why your main.py is not running - it's because code.py is found first and run.

adafruit_support_carter
 
Posts: 12039
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.