Hello all,
I have an arduino pro mini 3.3V that will be powered by a li-ion battery through the RAW pin. I need to get voltage and current readings while the system is being powered by battery.
I have seen suggestions like INA219, INA226, ACS712 and when I ask sellers on Amazon, they say it is not good for small currents (mA range) and voltages (less than 10V). I also need to get breakouts, if that is the solutions, that are already soldered as I do not have a soldering iron.
Please, any suggestions on this? I have also seen suggestions for a voltage divider (how to decide resistor values to use for this?) for measuring voltage and a shunt resistor for current but I don't fully understand the setup (Article I say this).
I would also appreciate help for best fuel guage breakout for measuring the battery charge, looked into this from Adafruit and this from DFRobot, both MAX1708. Basically, if I could put this all in one Amazon cart, that would be best.
Thank you for the help.
Thank you, will look at this
1 Like
Measuring is one thing, but not the same as using a calibrated meter to know what the real numbers are. Best to invest a bit of money on a digital volt/Ohmmeter that can measure currents. They are reasonably accurate.
I have a multimeter but I want to get these measurements periodically over the course of the system running automatically basically
Saw this breakout suggested in this article. Would be hooking up VIN to battery positive terminal and VOUT to RAW then the GND together work for me?
No, you can't measure current by simply measuring voltages no matter what you do to them.
No, Vout must go to an Arduino A/D pin so you can measure the generated voltage in order to compute the current. At least that is by the chip data sheet. I don't know about the circuit board and what they have done to support the chip. Do you have a data sheet for the circuit board?
If you wanted to do fully self contained battery voltage and current usage then you would be better off looking at fuel gauge IC's
Sparkfun use the BQ27441-G1A ; this measures current and voltage along with SoC of the cell. The MAX17043 looks reasonable too but this only measures voltage to calculate SoC so you would need current to be measured separately. Fuel gauges would be reasonably well calibrated too and handle lower currents.
I personally use the BQ27441 in projects as you can read current and voltage and this can also be used without a LiPo and powered from a 5V or 3.3V rail to monitor.
Seems there is a cheap board with it on from Digikey ;
You'll need one, at least for measuring current. Keep in mind that all measured voltages have to be within the GND to Vcc range. That's the same for breakout boards.
If you power the Pro Mini at the Vcc pin instead of the RAW pin, you can read the battery voltage without adding any additional parts. But that wouldn't give you the current measurement.
So I can add a resistor and connect it like I suggested before? I've realized the board must have other peripherals for it to measure voltage and current since someone has used it to measure both before: video
I need a soldering iron for measuring current? I do not understand
That would require it to be at exactly 3.3V right?
No. The lithium battery will vary between 4.2V fully charged down to 3.5V or less when mostly discharged. The Pro Mini will run just fine at 8MHz within that range when powered at Vcc. However, other sensors or devices that may be in your circuit may require 3.3V to run properly.
Anyway, if you connect the battery directly to Vcc, you can measure via ADC the voltage of the built-in 1.1V "band gap" fixed voltage source in the Atmega328P with reference to Vcc. So as the battery discharges and the Vcc voltage drops, the band gap voltage will read as a higher ADC value. The logic seems a bit backwards, but it does work.
So what other devices are in your circuit other than the Pro Mini?
Edit: Well here's a sketch that demonstrates the method:
// Function created to obtain chip's actual Vcc voltage value, using internal bandgap reference
// This demonstrates ability to read processors Vcc voltage and the ability to maintain A/D calibration with changing Vcc
// Now works for 168/328 and mega boards.
// Thanks to "Coding Badly" for direct register control for A/D mux
// 1/9/10 "retrolefty"
int battVolts; // made global for wider avaliblity throughout a sketch if needed, example a low voltage alarm, etc
void setup(void)
{
Serial.begin(9600);
Serial.print("volts X 100");
Serial.println( "\r\n\r\n" );
delay(100);
}
void loop(void)
{
battVolts=getBandgap(); //Determins what actual Vcc is, (X 100), based on known bandgap voltage
Serial.print("Battery Vcc volts = ");
Serial.println(battVolts);
delay(1000);
}
int getBandgap(void) // Returns actual value of Vcc (x 100)
{
// For 168/328 boards
const long InternalReferenceVoltage = 1059L; // Adjust this value to your boards specific internal BG voltage x1000
// REFS1 REFS0 --> 0 1, AVcc internal ref. -Selects AVcc external reference
// MUX3 MUX2 MUX1 MUX0 --> 1110 1.1V (VBG) -Selects channel 14, bandgap voltage, to measure
ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
delay(50); // Let mux settle a little to get a more stable A/D conversion
// Start a conversion
ADCSRA |= _BV( ADSC );
// Wait for it to complete
while( ( (ADCSRA & (1<<ADSC)) != 0 ) );
// Scale the value
int results = (((InternalReferenceVoltage * 1024L) / ADC) + 5L) / 10L; // calculates for straight line value
return results;
}
2 Likes
I have a BME280, a DS3231 and a SD card reader w/ SD card for recording data.
It is interesting to know the battery can connect to VCC, I thought if it was not exactly 3.3V, it had to feed through RAW. Thank you for this info. What do you think of the MAX471 I shared?
From Arduino website, I want to understand better:
Power
The Arduino Pro Mini can be powered with an FTDI cable or breakout board connected to its six pin header, or with a regulated 3.3V or 5V supply (depending on the model) on the Vcc pin. There is a voltage regulator on board so it can accept voltage up to 12VDC. If you're supplying unregulated power to the board, be sure to connect to the "RAW" pin on not VCC. The power pins are as follows:
RAW For supplying a raw voltage to the board. VCC The regulated 3.3 or 5 volt supply. GND Ground pins.
What would qualify as unregulated voltage if a battery that the voltage will flunctuate can be fed through VCC?
The BME280 will operate over a range of voltages, but tops out at 3.6V. And SD cards are 3.3V devices. So you probably should feed the battery into a voltage regulator. But I suspect the 3.3V regulator on the Pro Mini may have difficulty powering an SD card. It may not provide enough current, depending on the card. You would need a very low dropout regulator to produce 3.3V from a lithium battery.
Sorry, I don't know anything about the MAX471.
I don't quite remember the SD card I have but I think it's this. I can run the arduino on battery for like 5 minutes and see if it writes to the SD card.
Thank you for your help.
That's the typical usage. But if you look at the datasheet of the ATmega328P, you'll find that it can in fact operate over a wide range of voltages, the only limitation being that the processor speed has to be reduced for lower voltages (8MHz at 3.3V versus 16MHz at 5V).
Others may know better about this, but I think that while a lithium battery supply is not regulated, it behaves much like a regulated supply, particulary in the short run - there's really no noise or spikes, but of course over time the voltage will drop as the battery discharges.
I've built a number of circuits which have an 8MHz Pro Mini powered by an 18650 lithium battery at the Vcc pin, and have never had a problem. But you have those other devices that need 3.3V, so you'll need to use a 3.3 regulator somewhere. The question is whether the one on the Pro Mini is up to the task. Have you picked out an SD card module yet? Some of them have regulators on board, but not particularly good ones.
The issue on regulators is dropout voltage - how much higher than 3.3V the input to the regulator has to be for it to produce 3.3V.
1 Like