Battery Evenness Tester Attempt 2

Posted on 23/08/2017 by Adam

I still want to see if my battery bank discharges and charges evenly. So with version 2 of the code and a replacement module (and a theory or two about why it didn’t work last time), it’s time for a second attempt.


//Battery Evenness Tester Thingy by http://AdamWelch.Co.Uk

// LCD5110_Graph Library Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//      SCK  - Pin 8
//      MOSI - Pin 9
//      DC   - Pin 10
//      RST  - Pin 11
//      CS   - Pin 12
//
#include <LCD5110_Graph.h>

LCD5110 myGLCD(8,9,10,11,12);

extern uint8_t SmallFont[];

float I0 = 0.0;
float I1 = 0.0;
float I2 = 0.0;
float I3 = 0.0;
float I4 = 0.0;
float I5 = 0.0;
float I6 = 0.0;
float I7 = 0.0;
float V0 = 0.0;
float V1 = 0.0;
float V2 = 0.0;
float V3 = 0.0;
float V4 = 0.0;
float V5 = 0.0;
float V6 = 0.0;
float V7 = 0.0;
int ZeroRead0 = 511;  //Adjust according to zero point reading
int ZeroRead1 = 512;
int ZeroRead2 = 513;
int ZeroRead3 = 512;
int ZeroRead4 = 511;
int ZeroRead5 = 512;
int ZeroRead6 = 513;
int ZeroRead7 = 512;

void setup() {  
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}

void loop() {

V0 = (((analogRead(A0) - ZeroRead0) / 1023.0) * 5000); // Gives milliVolt
I0 = (V0 / 185.0);  // mV per Amp
V1 = (((analogRead(A1) - ZeroRead1) / 1023.0) * 5000);
I1 = (V1 / 185.0);
V2 = (((analogRead(A2) - ZeroRead2) / 1023.0) * 5000);
I2 = (V2 / 185.0);
V3 = (((analogRead(A3) - ZeroRead3) / 1023.0) * 5000);
I3 = (V3 / 185.0);
V4 = (((analogRead(A4) - ZeroRead4) / 1023.0) * 5000);
I4 = (V4 / 185.0);
V5 = (((analogRead(A5) - ZeroRead5) / 1023.0) * 5000);
I5 = (V5 / 185.0);
V6 = (((analogRead(A6) - ZeroRead6) / 1023.0) * 5000);
I6 = (V6 / 185.0);
V7 = (((analogRead(A7) - ZeroRead7) / 1023.0) * 5000);
I7 = (V7 / 185.0);

  myGLCD.clrScr(); // Clear Screen buffer
  myGLCD.print("0:",0,0);
  myGLCD.printNumF(I0,2,11,0);
  myGLCD.print("1:",42,0);
  myGLCD.printNumF(I1,2,53,0);
  myGLCD.print("2:",0,12);
  myGLCD.printNumF(I2,2,11,12);
  myGLCD.print("3:",42,12);
  myGLCD.printNumF(I3,2,53,12);
  myGLCD.print("4:",0,24);
  myGLCD.printNumF(I4,2,11,24);
  myGLCD.print("5:",42,24);
  myGLCD.printNumF(I5,2,53,24);
  myGLCD.print("6:",0,36);
  myGLCD.printNumF(I6,2,11,36);
  myGLCD.print("7:",42,36);
  myGLCD.printNumF(I7,2,53,36);   

  myGLCD.update();
  delay(250);
}

Be the first to leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *