Author Topic: Help with voltmeter project  (Read 2109 times)

wcat

  • Newbie
  • *
  • Posts: 1
Help with voltmeter project
« on: October 31, 2017, 01:15:25 am »
Hello

So I am a little stumped(hehe).  I am building a diy powerwall from re purposed laptop battery cells. Lots of them(over a thousand). To do this I have to charge them all up then discharge them to measure their capacity in mAh's, then charge them back up again where they will sit until I have scavenged enough to start building the 14s80p battery bank.

Needless to say my wife is giving me the stinkeye on the use of electricity to charging them all...twice. The nominal storage voltage of these cells should be around 3.7 volts. The tp4056 chips and my Opus charger charges them to 4.2 volts.

enter my plan for the digispark.

I would like to sample the voltage of 5 fully charged cells at a time and drain them down to 3.7 volts for storage. Better yet I would like to drain this voltage into cells that have yet to be charged.

I just managed to get the rubygem digiterm working for debugging but I am really pretty poor at writing Arduino code and the digispark I am even less familiar with. I chose the digispark because I had one on hand, that and about 6 nodemcu's.

I am looking for ideas or even if the spark can handle reading voltages accurately. I have searched around a bit on this forum and have found only one thread.  https://digistump.com/board/index.php/topic,1068.msg4398/topicseen.html#msg4398

I guess I am looking for any insight at all on going forward. Can I use all 5 pins as an analog read? Will it be accurate? Would I have to power the spark from a known source voltage or could it be run by the batteries themselves and still get accurate voltage readings as the battery voltage drops.

regards

edit:
wanna see something really neat and my inspiration?
http://www.diypowerwalls.com/showthread.php?tid=126

edit2:

I was able to get readings off a battery but they did not line up with my two dmm's. For example a 18650 Li-Ion at 4.10 volts measured by my meters showed 4.38 off the spark with the below code. So I made some progress but have more questions.

Code: [Select]
#include <DigiUSB.h>
// int reading = 0;

void setup() {
  DigiUSB.begin();
}

void get_input() {
  int lastRead;
  // when there are no characters to read, or the character isn't a newline
  while (true) { // loop forever
    if (DigiUSB.available()) {
      // something to read
      lastRead = DigiUSB.read();
      DigiUSB.write(lastRead);

      if (lastRead == '\n') {
        break; // when we get a newline, break out of loop
      }
    }

    // refresh the usb port for 10 milliseconds
    DigiUSB.delay(10);
  }

}

void loop() {
  //
  int reading = analogRead(1); //This is Pin2
  double result = doubleMap(reading, 0, 1024, 0, 5);
  // print output
  DigiUSB.println(result);
  // get input
  get_input();

}

double doubleMap(double x, double in_min, double in_max, double out_min, double out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

So my readings are off a battery with 3.77v is showing 4.04 in digiterm. hmmm

final edit

OK I broke down and ordered a mini. The readings were consistently off so I believe I could have just subtracted 27 or 28 and gotten accurate voltages.  This was all from usb power so I don't know what would have happened with varying input voltages powering the the spark.

gday
« Last Edit: November 01, 2017, 01:07:45 am by wcat »