Cigar box lid arduino/tp4056 clone charging

Joined
Oct 19, 2017
Messages
23
I made a little charge station so I could charge to 3.8 volts for long term storage. Since I am broke and need a lot of equipment they will be going into cold storage. Notice the little switch. In the up position it charges to 4.1 volts, down 3.8 volts. I noticed that if just ran battery negative to com and not B- on these 4056ets(cheap clones) it would not charge all the way to 4.2, which I liked. This worked nice for bulk charging and then I could top of 2 at a time for the Opus. These tp4056 clones have different pin allocations than the real tp's. They do not have a ce pin like the tp4056. So with a little trial and error I found bringing the isense pin high will shut them down. I had initially targeted pin 7 the timer/shdn pin but noticed nodropin current when attempting to control power. So went with isense. I also had planned on 9 slots but wiring space issues and the heat being produced by the buck converter put an end to that, so it can do 6, minus slot one that I smoked by putting one in backwards. I tried to make it easy to replace the chips for this very reason.

Arduino pro mini 5v loops through shutting them off and taking a voltage reading then deciding from there what to do. And her is the code I wrote for it. Cheers
Code:
const int readVoltagePins[6] = { A0, A1, A2, A3, A4, A5 };
const int chargePin[6]    = { 2, 3, 4, 5, 6, 7 };


float aRefVoltage      = 5.17;
float hysteresis       = 0.05;
float voltage        = 0;
float cutOff         = 3.75;

void setup() {
 // put your setup code here, to run once:
 for (int i = 0; i < 6; i++) {
  pinMode(chargePin[i], OUTPUT);
 }
 pinMode(12, INPUT_PULLUP);
 Serial.begin(9600);
}

void loop() {
 // put your main code here, to run repeatedly:
 int switchPos = digitalRead(12);
 // print out the value of the le switch
 // Serial.println(switchPos);

 if (switchPos == HIGH) {
  cutOff = 4.10;
 } else {
  cutOff = 3.80;
 }
// Serial.println(cutOff);

 for (int i = 0; i < 6; i++) {
  digitalWrite(chargePin[i], HIGH);
  delay(1500);
  int sensorValue = analogRead(readVoltagePins[i]);
  float voltage = (float) sensorValue * (aRefVoltage / 1024.0);

  if (voltage <= 1.00) {
   digitalWrite(chargePin[i], HIGH);
   Serial.print( F(" Slot-") );
   Serial.print(i + 1); // +1 to match slot number
   Serial.print( F(" = ") );
   Serial.print(voltage);
   Serial.println( F(" = NFG || Empty ") );
   // break; // Well that wasn't good
  }

  else if (voltage <= cutOff) {
   digitalWrite(chargePin[i], LOW);
   Serial.print( F(" Slot-") );
   Serial.print(i + 1); // +1 to match slot number
   Serial.print( F(" = ") );
   Serial.print(voltage);
   Serial.println( F(" Volts & Charging") );
  }

  else if (voltage >= cutOff) {
   digitalWrite(chargePin[i], HIGH);
   Serial.print( F(" Slot-") );
   Serial.print(i + 1); // +1 to match slot number
   Serial.print( F(" = ") );
   Serial.print(voltage);
   Serial.println( F(" Volts & !Charging") );
  }
 }
 delay(5000); // increase later
 
 for (int i = 0; i < 6; i++) {
  if (i == 5)
   Serial.println("   ");
 }
}






image_pmocat.jpg

image_tpcuuf.jpg

image_gcqwpx.jpg
 
Back
Top