# Monitor LIPO VOLTAGE with REFERENCE INTERNAL and SENSOR CURRENT with ANALOG 5V

¡¡¡¡¡¡Hello!!!!!!

I have read many forum topics, until I confirm that the best way to read a voltage from the LIPO battery is by using the internal Arduino reference [AnalogReferenceArduino](http://Hello! I have read many forum topics, until I confirm that the best way to read a voltage from the LIPO battery is by using the internal Arduino reference https://www.arduino.cc/reference/en/language/functions/analog-io / analogreference / ,,, I have used this scheme that I got in this forum from one of its members ,,, It works perfect ,,, lowers the voltage of all cells between 0.85 and 0.90, then you only have to read by The Analog Pin that you have used, if at that moment it gives us a raw value of 820, because to complete the 1.1v we do this simple formula, float volts = (analogRead (A0) * 4.555) / 1024; and we have the volts of the battery, if the value falls to 700 it would be about 3.3V and the alarm would go off if we wanted to. This is wonderful but I also need to measure the current with the ACS714 current sensor Pololu - ACS714 Current Sensor Carrier -5A to +5A, I understand that the only way to be able to read the voltage of the LIPO and the current of the components that I use It would be to change from AnalogReference (INTERNAL) to (DEFAULT) every time you want to read current or voltage, discarding the first values ​​as the datasheet says, my question is, Is there another way to use the current sensor and read the battery voltage without having to change the analog reference from internal to default using just an arduino board? Thanks) ,,, I have used this scheme that I got in this forum from one of its members @Wawa,,,

CIRCUIT MONITOR LIPO VOLTAGE

It works perfect ,,, lowers the voltage of all cells between 0.85 and 0.90, then you only have to read by The Analog Pin that you have used, if at that moment it gives us a raw value of 820, because to complete the 1.1v we do this simple formula, float volts = (analogRead (A0) * 4.555) / 1024; and we have the volts of the battery, if the value falls to 700 it would be about 3.3V and the alarm would go off if we wanted to.

``````void setup() {
// put your setup code here, to run once:
analogReference(INTERNAL);
Serial.begin(9600);

}

void loop() {
// put your main code here, to run repeatedly:
float volts = (analogRead(A0) * 4.55)/1024;
Serial.print("Valor bruto: ");
Serial.print("Volts: ");
Serial.println(volts);
}
``````

This is wonderful but I also need to measure the current with the ACS714 current sensor Pololu - ACS714 Current Sensor Carrier -5A to +5A, I understand that the only way to be able to read the voltage of the LIPO and the current of the components that I use It would be to change from AnalogReference (INTERNAL) to (DEFAULT) every time you want to read current or voltage, discarding the first values as the datasheet says, my QUESTION is:

-Is there another way to use the current sensor and read the battery voltage without having to change the analog reference from internal to default using just an arduino board?

Thanks!!!!!!!!!!

What stops you from using a 2 resistor voltage divider on the output of the ACS714 to match it's voltage to the internal reference?

Steve

10k 2.7k
5V----///--+--///----GND
|
A0 1.06V
OOPS, fixed, :-[

slipstick:
What stops you from using a 2 resistor voltage divider on the output of the ACS714 to match it's voltage to the internal reference?

Steve

Thanks, if I lower the signal to 1.1V I would also have to change the resolution, in the case of the ACS714 from 30A it is 66mV each A, at 5v each point from 0 to 1023 is 4.88mV but at 1.1v each point is of 1.1mV, I understand that I would only have to adapt the sensitivity variables and the voltage, right? Wouldn't this make the values unstable or would they be more accurate? Now I just have to try it.

``````/* Version simplificada.
This board is a simple carrier of Allegro’s ±30A ACS714 Hall effect-based linear current sensor.
Offers a low-resistance (~1.2 mΩ) current path and electrical isolation up to 2.1 kV RMS.
This version accepts a bidirectional current input
with a magnitude up to 30 A and outputs a proportional analog voltage (66 mV/A)
centered at 2.5 V with a typical error of ±1.5%.
It operates from 4.5 V to 5.5 V and is intended for use in 5 V systems.
Muestrea 100 valores y saca la media
Ejemplo para amperimetro y watimetrro a 12 V CC
*/
// Sensibilidad del sensor en V/A
float SENSIBILITY = 0.066; // Modelo 30A

int SAMPLESNUMBER = 100;

void setup()
{
Serial.begin(9600);
}

void printMeasure(String prefix, float value, String postfix)
{
Serial.print(prefix);
Serial.print(value, 3);
Serial.println(postfix);
}

void loop()
{
float current = getCorriente(SAMPLESNUMBER);
float power = 11.65 * current; // Voltaje alimentacion 11.65

printMeasure("Potencia: ", power, "W");
delay(300);
}

float getCorriente(int samplesNumber)
{
float voltage;
float corrienteSum = 0;
for (int i = 0; i < samplesNumber; i++)
{
voltage = analogRead(A0) * 5.0 / 1024.0;

corrienteSum += (voltage - 2.5) / SENSIBILITY;
}
Serial.println(pvoltage);
return(corrienteSum / samplesNumber);
}
``````

JCA34F:
2.7k 10k
5V----///--+--///----GND
|
A0 1.06V

According to the formula on this page Voltage Dividers - SparkFun Learn, which is where I checked if the resistances for the battery divider were good, to get 1.06 having 5v, they are 37 and 10k.

10K and 2.7K would also work but the diagram is the wrong way round, should be 10K to 5V, 2.7K to GND.

A voltage divider will not affect stability. For good accuracy use resistors with 1% or better tolerance.

Steve

jua123:
Is there another way to use the current sensor and read the battery voltage without having to change the analog reference from internal to default using just an arduino board?

No
You need a fixed reference voltage to measure 'voltage' (1.1volt Aref), and you need ratiometric default Aref to measure ratiometric current sensors like the ACS714.

slipstick:
What stops you from using a 2 resistor voltage divider on the output of the ACS714 to match it's voltage to the internal reference?

Measuring the ratiometric output of an ACS714 with a fixed Aref (1.1volt Aref) is asking for instability.
Leo..

The ACS714 output (mV/A) varies with supply voltage? Guess I zoomed over the datasheet too fast.

Wawa:
No
You need a fixed reference voltage to measure 'voltage' (1.1volt Aref), and you need ratiometric default Aref to measure ratiometric current sensors like the ACS714.
Measuring the ratiometric output of an ACS714 with a fixed Aref (1.1volt Aref) is asking for instability.
Leo..

Thanks!!! I have already tried it and it works very well !!!! ;D

I am going to copy the code, although it is still primitive ,,, we discard a value and wait 20 ms to stabilize the reference, but we could do a counter with millis () How to make a counter with millis () so that the program does not stop at any time.

``````/* Version simplificada.
This board is a simple carrier of Allegro’s ±30A ACS714 Hall effect-based linear current sensor.
Offers a low-resistance (~1.2 mΩ) current path and electrical isolation up to 2.1 kV RMS.
This version accepts a bidirectional current input
with a magnitude up to 30 A and outputs a proportional analog voltage (66 mV/A)
centered at 2.5 V with a typical error of ±1.5%.
It operates from 4.5 V to 5.5 V and is intended for use in 5 V systems.
Muestrea 100 valores y saca la media
Ejemplo para amperimetro y watimetrro a 12 V CC
*/
// Sensibilidad del sensor en V/A
float SENSIBILITY = 0.066; // Modelo 30A
float desecharValores;
int SAMPLESNUMBER = 100;

void setup()
{
Serial.begin(9600);
}

void printMeasure(String prefix, float value, String postfix)
{
Serial.print(prefix);
Serial.print(value, 3);
Serial.println(postfix);
}

void loop()
{

analogReference(DEFAULT);

float current = getCorriente(SAMPLESNUMBER);
float power = 11.65 * current; // Voltaje alimentacion 11.65

printMeasure("Potencia: ", power, "W");

analogReference(INTERNAL);

for (int i = 0; i < 1; i++)
{
desecharValores = analogRead(A5);  // Drop a value for the arduino to stabilize the reference

}

delay(20); // We wait 20ms for the reference to stabilize

Serial.print("Valor bruto: ");
Serial.print("Volts: ");
float volts = (analogRead(A5) * 4.785)/1024;  //Operation to scale the analog value that we receive to the voltage that we have in the cell.
Serial.println(volts,3);

}

float getCorriente(int samplesNumber)
{

for (int i = 0; i < 1; i++)
{
desecharValores = analogRead(A0);// Drop a value for the arduino to stabilize the reference

}

delay(20); // We wait 20ms for the reference to stabilize

float voltage;
float corrienteSum = 0;
for (int i = 0; i < samplesNumber; i++)
{
voltage = analogRead(A0) * 5.0 / 1024.0;

corrienteSum += (voltage - 2.5) / SENSIBILITY;
}

float ivoltage = analogRead(A0) * 5.0 / 1024.0;;
Serial.print("Valor mV: ");
Serial.println(ivoltage,5);