Battery voltage drop when USB connected

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Gambalunga
 
Posts: 65
Joined: Thu Apr 30, 2020 10:45 am

Battery voltage drop when USB connected

Post by Gambalunga »

I have a clock project that uses a Feather M0 Express coupled to an Adalogger Featherwing, a 7 segment LED backpack and uses a Adafruit PAM8302 - Mono 2.5W Class D Audio Amplifier to produce sound. I have a LiPo battery connected so that the clock functions for at least a day (or 2) if the USB power is disconnected.
I have yet to implement some code that will let me know when USB power is connected: see viewtopic.php?t=199750

I have written the following code to give a low battery warning:

Code: Select all

if (seconds % 5 == 0) {  // check battery once every 5 seconds
    checkBattery();
  }
and

Code: Select all

void checkBattery() {
  float measuredvbat = analogRead(VBATPIN);
  measuredvbat *= 2;     // we divided by 2, so multiply back
  measuredvbat *= 3.3;   // Multiply by 3.3V, our reference voltage
  measuredvbat /= 1024;  // convert to voltage
  // Serial.print("VBat: ");
  // Serial.println(measuredvbat);
  if (measuredvbat <= 3.5) {          // if battery is low sound beep and flash bat
    digitalWrite(switchAmp, HIGH);    // put amp off standby
    AudioPlayer.play("beep.wav", 0);  // beep
    delay(50);
    digitalWrite(switchAmp, LOW);  // put amp on standby
    time_now = millis();
    while (millis() <= (time_now + 1000)) {  // millis used for a non blocking delay
      clockDisplay.drawColon(false);
      clockDisplay.println("BAT ");
      clockDisplay.writeDisplay();
    }
  }
}
In experimenting I had USB power disconnected for over 24 hours. The low battery warning was not functioning however when I connected the USB to upload a new variation the low battery warning started functioning and continued for about 10 minutes (presumably the charge level ha sufficiently increased) . It is almost as thought there was a voltage drop of the battery output when the charger started to charge the battery.

Any idea why this may be?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Battery voltage drop when USB connected

Post by adafruit_support_bill »

If running solely on battery power and the battery voltage drops below the dropout voltage of the 3.3v regulator, the 3.3v rail will start to sag. And, since that is the default reference voltage for the ADC, the measured battery voltage will appear to increase.

If the processor you are using has an alternate, lower-voltage analog reference, you could use that. Otherwise, you need to set your low-battery detection threshold a bit higher.

User avatar
Gambalunga
 
Posts: 65
Joined: Thu Apr 30, 2020 10:45 am

Re: Battery voltage drop when USB connected

Post by Gambalunga »

Thanks, I will try 3.6v and see if that works. I am planning to use the eventual clock on battery power only overnight, say a maximum of 10 hours, and then recharge it during the day.
I am using a 2000 mAh battery which seems to last more than 48 hours (without a wake-up alarm) but the last thing I want is for the clock to start beeping in the middle of the night so I would not want it to arrive at low battery warning in less than at least 12 hours. Also if the wake-up alarm sounds, up to 4 minutes of music, that will also consume battery power for the amp and speaker.
Peter

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

Return to “Feather - Adafruit's lightweight platform”