Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
In order to accurately know the charge, you need to integrate the power taken from the battery when discharging and reported to it when charging. Usually special microcircuits are used for this.
If high accuracy is not needed, only the battery voltage can be measured. In this case, non-linearities are possible or the measured percentage of charge can sometimes float, but the circuitry and code are much simpler.
If we are talking about lithium, and high accuracy is not needed, then detailed instructions are here:
https://vk-book.ru/uroven-zaryada-akkumulyatora-18...
If you need to measure the battery voltage and it does not exceed 5 volts, then something like this:
#defin Akym //номер пина к которому подключен аккумулятор (A0-A7)
void setup(){
Serial.begin(9600);}
void loop(){
int i=analogRead(Akym);//возвращает цифровое значение напряжения в диапазоне 0-1023
int a=map(i,0,1024,0,5);//преобразование из цифрового диапазона , в диапазон напряжения 0-5 вольт
Serial.println(i);//Вывод результатов
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question