Standby battery pack

Well i plugged it all in and didnt upload the code for the pulses, but the pack is not turning off. I think its because the servo keeps humming after stopping. Do I need to detach it or something?

The servo moves fine but after reaching the desired position it stops and holds there, but as it holds, it hums. Im guessing this is just wasting energy.

Your drawing looks fine to me but you need a VCC (5V) wire if not powering from USB.
Many cheap low cost servos do that, I guess that's the cost of "economically priced" :slight_smile: , sometimes a little spring force or something will muffle them or mount them on something solid that doesn't resonate like a guitar body.
If you detach, you should save the current position so you can write it back before reattaching (as long as the servo is not moved while detached):

currentPos = servo.read();
servo.detatch();
// and later,
servo.write(currentPos);
servo.attach(Pin);

Marciokoko:
You mean like this:

No, not actually like that, like the circuit given in #3, the one with the required base resistor....

Oh thanks! Forgot the base resistor.

Ok while I get this tested, (Im re-charging my lipo before I test the new code with servo detach and pulse code), I noticed that the LED lights for rx/tx on the nano remained lit throughout my delay of 1 hr with the old code. Why would that happen?

Here is the code:

#include <LiquidCrystal.h>
#include <Servo.h>
Servo servo1;
//Servo servo2;
int servo1pin = 8;
int servo2pin = 9;
int angle1 = 0;
//int angle2 = 0;
float tempVoltage=0.0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(){
  lcd.begin(16, 2); 
  lcd.setCursor (0,0);
  lcd.print("Koffee Servo");
  lcd.setCursor(0,1); 
  lcd.print("Lipo Test");
  delay(1000);
  Serial.begin(9600); 
  servo1.attach(servo1pin); ATTACH IN LOOP
}

void loop(){
  servo1.write(angle1);
  // Servo #1 ~ 2.5 secs
  for(angle1 = 0; angle1 < 180; angle1++)  { 
    //Serial.println(angle1);                                 
    servo1.write(angle1);               
    delay(50);                   
  }
  
  //Read/Display voltage & wait
  readVoltage();
  delay(3600000); //3600000~ 1 hr
  
}


void readVoltage(){
  int analog_val=analogRead(A0); // read A0 and store it in analog_val
  tempVoltage = (analog_val * 5.0)/1024.0;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("V=");
  lcd.print(tempVoltage); //print v to LCD
}

Ok I uploaded this code to my nano but its not working:

#include <LiquidCrystal.h>
#include <Servo.h>
Servo servo1;
int servo1pin = 8;
int servo2pin = 9;
int angle1 = 0;
float tempVoltage=0.0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

//Pulse code for lipo alive
unsigned long iStart; // interval start
const unsigned long iEnd = 15000; // interval end
const int pLen = 50; // pulse length
const byte pPin = 7; // pulse pin

void setup(){
lcd.begin(16, 2); 
lcd.setCursor (0,0);
lcd.print("Koffee Servo");
lcd.setCursor(0,1); 
lcd.print("Lipo Test");
delay(1000);
pinMode(pPin,OUTPUT); //pulse pin 
Serial.begin(9600); 
}

void loop(){
servo1.attach(servo1pin);
servo1.write(angle1);
for(angle1 = 0; angle1 < 180; angle1++)  { 
  //Serial.println(angle1);                                 
  servo1.write(angle1);               
  delay(50);                   
}

servo1.detach();
keepAlive();  
readVoltage();
delay(3600000); //3600000~ 1 hr
}

void keepAlive(){
Serial.println("pulsing");
digitalWrite(pPin,millis() - iStart < pLen);
if(millis() - iStart > iEnd)
  iStart += iEnd;
}

void readVoltage(){
int analog_val=analogRead(A0); // read A0 and store it in analog_val
tempVoltage = (analog_val * 5.0)/1024.0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("V=");
lcd.print(tempVoltage); //print v to LCD
}

The connections are as were suggested. Im using D7 off the nano to send a pulse through a resistor to a 2n2222 transistor, out to GND and 5V from the battery:

NOTHING can happen during:

delay(3600000); //3600000~ 1 hr

The processor is blocked for 1 hr, you need to learn "blink without delay" and "several things at the same time"

Ok I modified it to this. And I changed the interval end value from 15000 to 5000 because the battery pack would turn off too quickly:

#include <LiquidCrystal.h>
#include <Servo.h>
Servo servo1;
int servo1pin = 8;
int servo2pin = 9;
int angle1 = 0;
float tempVoltage=0.0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

//Pulse code for lipo alive
unsigned long iStart; // interval start
const unsigned long iEnd = 5000; // interval end
const int pLen = 50; // pulse length
const byte pPin = 7; // pulse pin
unsigned long previousMillis = 0;        // will store last time was updated
const long interval = 3600000; 

void setup(){
lcd.begin(16, 2); 
lcd.setCursor (0,0);
lcd.print("Koffee Servo");
lcd.setCursor(0,1); 
lcd.print("Lipo Test");
delay(1000);
pinMode(pPin,OUTPUT); //pulse pin 
Serial.begin(9600); 
}

void loop(){  
  unsigned long currentMillis = millis();
  Serial.println(currentMillis - previousMillis);
  
  //If deltaTimeElapsed is less than target interval, then keep alive
  if (currentMillis - previousMillis <= interval) {
    keepAlive();
    Serial.println("keepAlive");
   } else { //if deltaTimeElapsed is GREATER than target interval, spin
    Serial.println("spinServo");
    previousMillis = currentMillis; //sets previous-0 to current-3600
    spinServo();
    readVoltage();
   }
}

void spinServo(){
  servo1.attach(servo1pin);
  servo1.write(angle1);
  for(angle1 = 0; angle1 < 180; angle1++)  { 
    servo1.write(angle1);               
    delay(50);                   
  }
  servo1.detach();
}

void keepAlive(){
  digitalWrite(pPin,millis() - iStart < pLen);
  if(millis() - iStart > iEnd)
    iStart += iEnd;
}

void readVoltage(){
  Serial.println("readVoltage");
  int analog_val=analogRead(A0); // read A0 and store it in analog_val
  tempVoltage = (analog_val * 5.0)/1024.0;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("V=");
  lcd.print(tempVoltage); //print v to LCD
}

It works for 1 hour but the battery pack standsby and nano turns off..

756E6C:

You say a 50ms pulse every 15 seconds through a 56Ω resistor kept yours alive but you have a 1k R to the base of the 2n2222. Im confused then, did you mean the dummy load is your 56 Ω resistor?

So I checked other posts on the web and the 56 is the dummy load, Im using a LED. The 1k resistor is at the base as explained. However my battery pack keeps turning off. It has its own set of leds that it uses for 2 purposes:

  1. Displaying all 4 blue showing its active or in use.
  2. Displaying state of charge in red.

I turn on the battery pack by pressing a button it has, it activates as shown by the 4 leds in blue. The nano and my lcd power up and start to work as expected. 10 s later, the 4 leds blue on the battery pack turn off but the nano and lcd are still on. 20s after that the nano and lcd power down completely.

What else could I try?

What is the minimum current that will keep your power pack from automatically shutting off?

OK yesterday I checked the LED that I have as a dummy load and flipped it since I had it on wrong. The LED would Pulse as it should and nano/lcd worked fine for at least an hour until the LED stopped blinking. It almost looked like it was dimmed a lot but because nano/lcd still worked I let the experiment run and it ran for quite a few hours until this morning when for some reason it had stopped working. The nano/LCD and the blue lads we're all off however the battery pack is still pretty well charged at 5.08 V so something else must have happened, possibly the LED started fine but burnt out gradually.

What I would like to understand is if the code is set to send a pulse from the pin to the battery pack as if something were drawing current from it, I'm not entirely clear as to why we need the LED. But it seems the led burning out is indeed related to the problem.

This thread seems to be drifting off toward Never-Never land so lets start over and first find out the minimum current that will keep your power pack alive. Make sure it is full charged, then connect it to a bare breadboard, + wire to the red rail and - wire to the blue rail, put a 180 or 220 Ohm, 1/4 or 1/2 watt resistor across red and blue rails and see if the power pack stays on, if not, add another of the same resistor in parallel with the first and try again, keep adding resistors until the power pack stops shutting off automatically. Report back with how many resistors of what values and we can go from there.

Ok I started with 220Ω resistors. 3 is enough to keep it on, I counted more than 30s with all 3 of them on. What I have in my project, to the base of the transistor it a 1.1kΩ.

So, you need about 73mA, I would use a 56 Ohm 1 Watt (90mA) or 2 100 Ohm 1/2 Watt (100mA) resistors for dummy load.
Put your Nano on the breadboard and connect the dummy load and transistor like this with a 1k resistor from pin 8 to base.
out.png
Power the Nano from computer USB, not from powerpack yet, you will need a jumper from powerpack - to Nano GND.
Upload this test sketch to Nano and adjust interval time and pulse length to the minimum that will keep the powerpack alive, we start with a 5 second interval and 100 mS pulse length, start Serial monitor and set to 115200 baud, in the top of serial monitor type desired interval in seconds, for example, 10 seconds, type letter "i" then 10, like i10 then [ENTER], for pulse length of 75 mS, type p75[ENTER], increase interval time a few seconds at a time until the powerpack starts shutting down then back up a second or 2, decrease pulse length the same way but I would stay above 50. I found an interval of 12 seconds and pulse of 50mS works for one of mine.

unsigned long iStart; // interval start
unsigned long iEnd = 5000; // interval end
unsigned int pLen = 100; // pulse length
const byte pPin = 8, // pulse pin
           ledPin = 13; // led pin
void setup()
{
  Serial.begin(115200); //set serial monitor to match
  pinMode(pPin,OUTPUT);
  pinMode(ledPin,OUTPUT);
  prntIt();
}
void loop()
{
  digitalWrite(pPin,millis() - iStart < pLen);
  digitalWrite(ledPin,digitalRead(pPin));
  if(millis() - iStart > iEnd)
    iStart += iEnd;
  while (Serial.available() > 0) {
    char inChar = Serial.read();
    if(inChar == 'i')
      iEnd = Serial.parseInt() * 1000;
    else if(inChar == 'p')
      pLen = Serial.parseInt();
    else
    {  
       Serial.println("invalid input");
       while(Serial.available() > 0)
         Serial.read();
    }
    prntIt();
  }  
}
void prntIt()
{
  Serial.print("interval = ");
  Serial.print(iEnd / 1000);
  Serial.print("  pulse length = ");
  Serial.print(pLen);
  Serial.println("\n");
}

ok well im using pin 7 because 8 is busy.

Did you mean to post new code? Because I think you forgot to paste it in :slight_smile:

Here is a resistor I got (not currently in the circuit). According to color code it is 47Ω:

resistorbatterypack.jpg

ps: when is this forum going to allow users to post an image/link from the start? :slight_smile:

resistorbatterypack.jpg

Did you mean to post new code? Because I think you forgot to paste it in :slight_smile:

That was my fault (I'm old) :confused:
47 is a little low, but it's only going to be on for a few mS at a time.
BTW, are you sure that powerpack can do 5 servos at the same time? What's it's mAh rating?

That's OK I'm probably older.

It's a 23,000mah pack.

OK I'll look or a bigger R. The 47 is running right now. So far so good but the led lasted about 12 hours so.

And yeah the 47R is getting a but warm

So this would be a simple circuit for it: