MKR 1010 and NANO 33 IoT both stop running when USB is Removed

Both units have 5V applied to VIN. both run with no issue as long as the USB cable is connected but stop when cable is unplugged. Neither unit gets past setup and does not run loop(). plug cable back in and it works. I have verified the voltage on the VIN pin is +4.98v and also verified the ground connections. Any suggestions are welcome at this point.

I am running with fastLED. Example code does the same thing.

Welcome to the forum

Does your sketch have anything like

while (!Serial);

in it ?

Please post your sketch, using code tags when you do

No serial.

Example code from fastled ;library:

/// @file    DemoReel100.ino
/// @brief   FastLED "100 lines of code" demo reel, showing off some effects
/// @example DemoReel100.ino

#include <FastLED.h>

FASTLED_USING_NAMESPACE

// FastLED "100-lines-of-code" demo reel, showing just a few 
// of the kinds of animation patterns you can quickly and easily 
// compose using FastLED.  
//
// This example also shows one easy way to define multiple 
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014


#define DATA_PIN    3
//#define CLK_PIN   4
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS    64
CRGB leds[NUM_LEDS];

#define BRIGHTNESS          96
#define FRAMES_PER_SECOND  120

void setup() {
  delay(3000); // 3 second delay for recovery
  
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}


// List of patterns to cycle through.  Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };

uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
  
void loop()
{
  // Call the current pattern function once, updating the 'leds' array
  gPatterns[gCurrentPatternNumber]();

  // send the 'leds' array out to the actual LED strip
  FastLED.show();  
  // insert a delay to keep the framerate modest
  FastLED.delay(1000/FRAMES_PER_SECOND); 

  // do some periodic updates
  EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
  EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
}

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern()
{
  // add one to the current pattern number, and wrap around at the end
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

void rainbow() 
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, NUM_LEDS, gHue, 7);
}

void rainbowWithGlitter() 
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

void confetti() 
{
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, NUM_LEDS, 10);
  int pos = random16(NUM_LEDS);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
}

void sinelon()
{
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy( leds, NUM_LEDS, 20);
  int pos = beatsin16( 13, 0, NUM_LEDS-1 );
  leds[pos] += CHSV( gHue, 255, 192);
}

void bpm()
{
  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  for( int i = 0; i < NUM_LEDS; i++) { //9948
    leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
  }
}

void juggle() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds, NUM_LEDS, 20);
  uint8_t dothue = 0;
  for( int i = 0; i < 8; i++) {
    leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
}

Which board are you using ?

Most require at least 7V on the VIN pin as voltage supplied to it has to be passed through a voltage regulator

Depending on the board being used you may be able to power it via the 5V pin

MKR wifi 1010 and NANO33 IoT both exhibit the same thing. I am using a breadboard to connect the processors to the LED strips. The sample code above drives one strip of 50 leds. As soon as I remove the USB the animation on the strips stop. Plug USB back in and Walla... works again.

I assumed the 5v would be sufficient. Yesterday I removed the USB to computer and the unit ran for about 5 hours on the battery without issue. Today no workie. Confused. The Battery is a power bank that supplies 5v to USB. This connection goes through a power regulator to the breadboard that uses a separate USB input. Output is 5v. I do have a 7.4v Lipo I can use. I need regulator to the LEDs as they get destroyed if voltage is over 5.5v. I will supply the 7.4v directly to the VIN on the processor. The breadboard also has a wall wort that provides 6.5v and is regulated down to 5v and 3.3v. Both worked yesterday just fine. I changed out he MKR wifi 1010 for the NANO 33IoT and it also behaves the same. I will try the 7.4v today to see if that solves it.

The Nano33IoT has a DC-DC converter for its 3V3.
The '5V' pin is only the output VUSB (aka VBUS), it's live only when USB is plugged in.
Your WS2811's won't run this way if they're 'powered' via the Nano33 '5V' somehow.

And when the 2 pads on the reverse of the board are bridged

I am wired exactly like that. I don't have anything connected to the 5V pin or the 3.3V pin on the board as I believe those are outputs. I disconnected to power supply to the board and was surprised to see the LEDs work as they are driven by the 5V input to the board. It appears as though the LEDs are being powered by the VIN pin on the NANO33 getting its power from the PC USB connected to the NANO. Is that correct or is something on the NANO broken?

Not sure what that means.

As you can see, I have invested some time and effort here. Perhaps you could reciprocate and post a wiring diagram of what you're doing.

"I am wired exactly like that" refers to your first diagram with the voltmeter. I will draw up a schematic and possibly post a picture of the board soon. I do appreciate your time here! Thanks


5v rail is on the right and 3.3v is on the left

The big block on the bottom supplies power either through wall wort or USB to battery. Blue blocks are connected to LED strips and red tin the middle is a level converter to talk to the LEDs

I see a level-shifter module without 3V connected to its 'LV' terminal.
And there's the matter of D2 and D3 going to that module's HV1 and HV2.

3.3v is going to LV and GND. other side od Level shifter is HV = 5v and GND

closer examination shows lv data going to leds and hv going to NANO... its backwards thanks will retry

Looking at that stuff is a lot easier when the wire color used 'means' one thing.
For instance, black should be Gnd. I suggest green for 3V and red for 5V.
Why are you using 3V (?) from the power supply widget instead of the Nano33's ?

The issue has been resolved. There were 2 issues:
The wiring of the level shifter. (the wire colors were all i had on hand).
And as it turns out my main program did have a while(!Serial). I thought I took all the serial stuff out.

Thanks for all your help...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.