How to keep a Powerbank awake

Using a powerbank as a battery for an Arduino project is usually a good idea. Powerbanks are available for little money, have large capacities, can be charged easily via USB and could be used for charging mobile devices as well.

When powering an Arduino it may happen that the powerbank simply turns off after a while. Powerbanks are just way too smart sometimes.

But why? Some clever circuit inside the powerbank detects how much power is drawn. An Arduino usually does not need so much power compared to a charging mobile device. If the amount of power drawn is too small the powerbank turns off.

Searching the internet for enlightenment on this issue leads to the following pages:
http://www.instructables.com/id/USB-External-Battery-Packs-on-Arduino-turns-OFF/
http://dorkbotpdx.org/blog/paul/battery_pack_load
http://held-im-ruhestand.de/hardware/powerbank-autooff.html

To keep such a clever powerbank awake when running an Arduino it is sufficient to trigger a load pulse every few seconds. The time interval depends on the powerbank.
A simple hardware setup of two resistors and a transistor in combination with a pulse generating software is sufficient to create a pulsed load on the powerbank. This way it does not turn off automatically after its time has passed.

The simple piece of software used to trigger the data pin works without the delay-function:

int USBBATTERYDATAPIN=8;
bool usbPinState = false;
int tweakcounter=0;
unsigned long previousMillis;
bool debugging=true;
void triggerUSBBatteryPin() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= 1000) {
    previousMillis = currentMillis;

    if( tweakcounter<=1 ) {
      if( debugging ) {
        Serial.print(F("Toggle USB battery pin: "));
        Serial.println(usbPinState?"low":"high");
      }
      digitalWrite(USBBATTERYDATAPIN, usbPinState?LOW:HIGH);
      usbPinState = !usbPinState;
    } else if( tweakcounter==9 ){ // start over again 8s later
      tweakcounter = 0;
      if( debugging ) {
        Serial.println(F("Reset tweak counter"));
      }
      return;
    }
    tweakcounter++;
    if( debugging ) {
        Serial.print(F("tweakcounter: "));
        Serial.println(tweakcounter);
      }
  }
}
Advertisements

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s