How measure battery voltage?

Status
Not open for further replies.
Sorry to post on this old thread, yesterday i soldered a 18650 ZB2L3 to a 18650 holder and started to play with it. i was thinking that it would be nice to graph the discharge curve of the cell, with a teensy reading polling voltage every seconds and sending it back to computer thougth USB.

Then i found this subject. So i understand what is a divider (2 resistances in series). Which i did on the breboard. And with my own voltmeter, i see it is correctly divided.
Owning a teensy 3.1, i tryied to identify those ADC port. Seems it is in the middle of the board. Do i need to solder my cable there ?
Also, the ZB2L3 use a big resistance to discharge the cell. But also the Teensy to monitor the voltage. This is going to impact the discharge rate right ?

So if i understand the thread, it is suggested to use a mosfet, controller by the teensy, to open the circuit just the time for the teensy to read value, and close it right after, so that diminishes the impact of thoses two added resistance in the discharge load. Am i correct ?

Is there any schematics around to make things more clear for my newby mind ?
 
Sorry to post on this old thread, yesterday i soldered a 18650 ZB2L3 to a 18650 holder and started to play with it. i was thinking that it would be nice to graph the discharge curve of the cell, with a teensy reading polling voltage every seconds and sending it back to computer thougth USB.

Then i found this subject. So i understand what is a divider (2 resistances in series). Which i did on the breboard. And with my own voltmeter, i see it is correctly divided.
Owning a teensy 3.1, i tryied to identify those ADC port. Seems it is in the middle of the board. Do i need to solder my cable there ?
Also, the ZB2L3 use a big resistance to discharge the cell. But also the Teensy to monitor the voltage. This is going to impact the discharge rate right ?

So if i understand the thread, it is suggested to use a mosfet, controller by the teensy, to open the circuit just the time for the teensy to read value, and close it right after, so that diminishes the impact of thoses two added resistance in the discharge load. Am i correct ?

Is there any schematics around to make things more clear for my newby mind ?

No, you don't need that work. I can read the battery with 3M and 1M resistors.

Code:
BATT ---- 3M ---- 1M ---- GND
              |
        Teensy Analog In

So you can use the 1.2V reference (as the teensy works up to 1.8V) setting it in this way:
Code:
analogReference(INTERNAL1V2);
analogReadAveraging(4);
analogReadResolution(12); // 0 to 4096, default is 1024
You can connect it to every analog input (A0 to A9 => pin 14 to pin 23) and read the battery voltage with analogRead(PIN).

The problem is that when you read, teensy will drain some current. If you want a stable value, you need to put a 0.1uF condensor between the Teensy input and GND and don't read the battery voltage every second but only every 30-60 seconds.
 
so basically tried what you did.
I have two exacts resistors, so it divides by two.
I only have 1uf capacitor not 0.1uF.

My code is as below
Code:
void setup()
{                
  Serial.begin(38400);
}

int val;
float volt;

void loop()                     
{
analogReference(DEFAULT);
analogReadAveraging(4);
analogReadResolution(12); // 0 to 4096, default is 1024
  val = analogRead(0);
  Serial.print("analog 0 is: ");
  Serial.println(val);
  volt = (3.3*val)/4096;
  Serial.print("voltage is :");
  Serial.println(volt);
  Serial.println(volt*2);
  delay(1000);
}

output is like this in serial monitor:
Code:
analog 0 is: 2436
voltage is :1.96
3.93
analog 0 is: 2440
voltage is :1.97
3.93
analog 0 is: 2443
voltage is :1.97
3.94

i understand at the beginning this is not very accurate, but after 5 minutes i only have 0.05v is difference between A0 read value and a real voltmeter. looks good.
Edit: now i have 0.2v of differences
this is quite big
 
Put the settings of the analog reading in the setup, you don't need to setup it each second.
Code:
analogReference(DEFAULT);
analogReadAveraging(4);
analogReadResolution(12); // 0 to 4096, default is 1024
should be in the setup, not in the loop.

And a 1uF is too much! Once the capacitor reached 3V, probably even if the battery falls down to 2.9V, you will probably still read the capacitor voltage of 3V for a while.
 
Status
Not open for further replies.
Back
Top