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:

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:

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: "));
      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"));
    if( debugging ) {
        Serial.print(F("tweakcounter: "));