Skateboard battery percentage monitor

I have a school project to make an electric skateboard’s pecentage shower.
I chose to use a Sparkfun card with an LCD.
I chose to find the battery voltage at which the skate stops, this value was 22.45V (the maximum voltage being 29.4V)
I graphed up the values on excel and got an equation to get the capacity of the battery in percentages as a function of the voltage.

The problem is that since the maximum voltage of the battery is 4.9V (after the measurement from the voltage divider bridge), I thought I could use the law of thirds and do :
(4.9*1024)/5.0~1003.52 round it up to 1004 to use as my value divider (*4.9) to get back to the true voltage.
Is it ok if I do it like that?
I’d like some advice. I also attached my excel values.
Thanks in advance.

Here’s my code :

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
int entre1 = A0;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // number of columns and lines of the LCD
  lcd.begin(16, 2);
   pinMode(entre1, INPUT);
  // Display message
  lcd.print("Capacity :");
}

void loop() {
  int Value1 = analogRead(entre1);                    //Value converted in 10 bit
  float Voltage1 = (Value1*(4.9 / 1004));           //4.9V = maximum voltage
  float Voltage2 = (Voltage1*6);                         //to get back to the true voltage
  if (Voltage2 < 22.45) {
    lcd.setCursor(12, 0);
    lcd.print("0");
    lcd.print("%");
  }
  else {
    int Percentage = ((Voltage2*14.442)-324.78);      //function got from the battery's discharge
    lcd.setCursor(12, 0);
    lcd.print(Percentage);
    lcd.print("%");
  }
  delay(1000);
}

Welcome to the Arduino forum. An excellent project for a first time project.

But, don't confuse battery voltage with battery capacity. The voltage is only dependent on chemistry and temperature of the battery. The capacity is based on the number of electrons forced into the battery to modify the chemistry of the chemical components. When electrons(current) is drawn from the battery that is measure in amperes over some time period, ie. ampere hours. That is the capacity of the battery.

A depleted storage battery will still have close to the original voltage, but cannot supply any current.

Yes, you can fake the capacity of a battery to do work by showing the voltage, and many commercial devices do that.

Paul

Hi Paul,
Thanks for the answer. By using the word capacity I meant the percentage of the battery left before the skate's motors stop running. :slight_smile:

Thanks,
Anthony

I meant the percentage of the battery left before the skate's motors stop running.

Isn't the whole battery still there when you plug the charger back in? So, isn't the percentage of the battery left 100% all the time? Don't you need to buy a new battery any time the %-age is less than 100%?

You still need to properly define just what it is you are measuring/predicting.

PaulS:
You still need to properly define just what it is you are measuring/predicting.

I meant battery life... But I think you already understood it :slight_smile:

I meant battery life… But I think you already understood it

The battery life is not predictable by measuring the voltage. Overcharging, high temperatures, and other factors can affect battery life.

Battery CAPACITY is the term you are looking for.

PaulS:
Battery CAPACITY is the term you are looking for.

You are right but I looked for a good amount of time to see if there was a better way to show this capacity without using a voltage measurement. For the few articles/projects, I found online, that's how they did it. Do you have any suggestions on how I should improve it?

Thank you.

One thing you haven't said is what TYPE of battery you are using. A simple (off-load) voltage measurement gives a reasonable approximation to available charge percentage for some battery types (mainy Li-based) but is completely useless for others.

And note that measuring the voltage under load, e.g. while driving motors, is not at all useful. Only the resting voltage tells you anything interesting.

Steve

slipstick:
One thing you haven't said is what TYPE of battery you are using. A simple (off-load) voltage measurement gives a reasonable approximation to available charge percentage for some battery types (mainy Li-based) but is completely useless for others.

Thanks for the answer, the battery is Li-Ion