Gemma + Microphone only works on USB Power

Wearable electronics: boards, conductive materials, and projects from Adafruit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
maxtheman36
 
Posts: 4
Joined: Fri Dec 02, 2016 4:49 pm

Gemma + Microphone only works on USB Power

Post by maxtheman36 »

I am using the Gemma v2 and a microphone: https://www.adafruit.com/product/1063
The microphone triggers a 35-pixel long NeoPixel strip.
I am using the same wiring as the Drum Project: https://learn.adafruit.com/gemma-powere ... ive-drums/

My issue is that everything works perfectly while I am connected to USB, but when I switch to battery power, the light's either flash at random, or continually stay lit.
I have tested multiple fully charged batteries from 105mAh - 2200 mAh all with the same result.

My suspicion is that it has something to do with the power being too 'dirty' for the microphone... perhaps it's too sensitive when working via battery? I've tested this with the Drum project code as well as my own code below (same results).

Any ideas on how to fix this anomaly?

Code: Select all

/****************************************
  Scrolling Sound Meter Sketch for the
  Adafruit Microphone Amplifier
****************************************/

#include <Wire.h>
#include <Adafruit_NeoPixel.h>

#define PIN 0

// Include the Matrix code for display
Adafruit_NeoPixel strip = Adafruit_NeoPixel(35, PIN, NEO_GRB + NEO_KHZ800);

const int maxScale = 100;
const int lowestZone = 30;
const int redZone = 90;

const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

void setup()
{
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  strip.setBrightness(80); //adjust brightness here
}


void loop()
{
  unsigned long startMillis = millis(); // Start of sample window
  unsigned int peakToPeak = 0;   // peak-to-peak level

  unsigned int signalMax = 0;
  unsigned int signalMin = 1024;

  while (millis() - startMillis < sampleWindow)
  {
    sample = analogRead(1);
    if (sample < 1024)  // toss out spurious readings
    {
      if (sample > signalMax)
      {
        signalMax = sample;  // save just the max levels
      }
      else if (sample < signalMin)
      {
        signalMin = sample;  // save just the min levels
      }
    }
  }
  peakToPeak = signalMax - signalMin;

  // map 1v p-p level to a 0% - 100% scale
  int displayPeak = map(peakToPeak, 0, 1023, 0, maxScale);

  // draw the new sample
  {
    if (lowestZone >= displayPeak)  // blank these pixels
    {
      restingState();
    }
    else if (displayPeak < redZone) // Bright Blue!
    {
      setStripColor(strip.Color(0, 0, 180));
    }
    else // Rainbows are awesome!
    {
     // setStripColor(strip.Color(255, 0, 0));
      rainbowCycle_New(0, strip.numPixels());
    }
  }
  strip.show();  // write the changes we just made to the display
  //delay(60);
}

void restingState()
{
  static int b = 0;
  static bool fadeIn = true;

  if (b >= 25)
    fadeIn = false;

  if (b <= 0)
    fadeIn = true;

  if (fadeIn) b++;
  else b--;

  setStripColor(strip.Color(0, 0, b));

}

void setStripColor(uint32_t c) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    // strip.show();
    // delay(wait);
  }
}

void rainbowCycle_New(int start, int finish) {
   
  static uint16_t i = 0;

  if(i>=finish)
  i = start; 

 for(uint16_t j=0; j<256*5; j++)
 {
   if(i< finish)
    {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + random(0, 254)) & 255));
      i++;
    }
 }
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

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

Re: Gemma + Microphone only works on USB Power

Post by adafruit_support_carter »

Post a photo of your setup showing all wiring connections.

Also, try a sketch that just uses the NeoPixels (no microphone) and see if that runs OK on battery.

User avatar
maxtheman36
 
Posts: 4
Joined: Fri Dec 02, 2016 4:49 pm

Re: Gemma + Microphone only works on USB Power

Post by maxtheman36 »

Thanks for the reply.
Yes, I have tested with NeoPixel Strand test (it works fine on battery)

I'm using the same wiring as the drum project:
gemma_drums-circuit-Layout.jpg
gemma_drums-circuit-Layout.jpg (28.58 KiB) Viewed 1054 times
I have attached a photo of my project on a breadboard (I'm using the Neopixel Gems instead of strips, but it should be the same):
http://imgur.com/a/UBxY9

*Edit to fix image links*

EDIT: inlining image
bread_board.jpg
bread_board.jpg (123.8 KiB) Viewed 1048 times

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

Re: Gemma + Microphone only works on USB Power

Post by adafruit_support_carter »

What are these two red wires connected to on the Gemma?
wires.jpg
wires.jpg (161.93 KiB) Viewed 1042 times

User avatar
maxtheman36
 
Posts: 4
Joined: Fri Dec 02, 2016 4:49 pm

Re: Gemma + Microphone only works on USB Power

Post by maxtheman36 »

I've annotated my image a bit to try to help :-)
Inkedwires_LI.jpg
Inkedwires_LI.jpg (841.76 KiB) Viewed 1041 times
My 3Vo is going onto the far left rail, and only connected to the microphone's VCC port
The other red wire is Vout on Gemma going onto the other two red rails (powering all the NeoPixels).


Any ideas? I don't really understand why the 3Vo output would be so all over the place when connected to a battery.
(I have a backup plan, I could always just buy a USB phone battery to power the project, but I'd like to use the LiPoly's I have)

Rodekater
 
Posts: 37
Joined: Sat Jun 14, 2014 10:18 am

Re: Gemma + Microphone only works on USB Power

Post by Rodekater »

could it be that the neopixel data is flowing back tru the ground and into the microphone ground? Maybe a small filtering capasitor between the + and - from the neopixel or the microphone can eliminate this.

User avatar
maxtheman36
 
Posts: 4
Joined: Fri Dec 02, 2016 4:49 pm

Re: Gemma + Microphone only works on USB Power

Post by maxtheman36 »

This is a really interesting idea, and it feels like the battery power may be causing the issue you're nothing (too much noise on the ground).
What type of capacitor should I try using (I'm trying 100uF now) and between what wires should I have it? I tried getting it between the neopixel's shared ground & the microphone's ground, but it didn't seem to work.
Rodekater wrote:could it be that the neopixel data is flowing back tru the ground and into the microphone ground? Maybe a small filtering capasitor between the + and - from the neopixel or the microphone can eliminate this.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: Gemma + Microphone only works on USB Power

Post by adafruit2 »

you should try just running some neopixel demo code - see if you can get that working well, there's a lot of wiring which can trip you up. make sure all grounds are tied together!!

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

Return to “Wearables”