Measuring power consumption of a circuit using an Arduino

Hello,
I am trying to measure the complete power consumption of a circuit. In this circuit I have four components,:

  • 1 Lipo battery (500mA)
  • 1 RTC (DS3231)
  • 1 Accelerometer (ADXL 345)
  • 1 RedBear Nano2

I would like to get the power consumption of each component, and the general power consumption, so the discharging curve of the battery. Right now I am using an Arduino Uno as a multimeter, the code is reported below:

void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
float current = voltage / 1000;
Serial.print(millis());
Serial.print(",");
Serial.print(voltage, 10);
Serial.print(",");
Serial.println(current, 10);
delay(500);
}

I have also an Arduino Due if more analogical Pin are needed, and I have resistors of different values.

My idea is to put each component in parallel with the battery and connect to each component a relatively small resistor and analyze the current and the voltage of this resistors. In this way I should get the actual voltage of each sensor in the circuit. Comparing it to the battery voltage I should get the measures I want. Is that idea correct? Should I change something?

Than you.

The data sheets for the parts will tell you the power consumption.

For the DS3231 RTC, the power consumption is too small for the Arduino to measure using a series resistor, and attempting to do so will probably cause the RTC to malfunction.

To measure the current required by the Nano, simply use your multimeter.

To maximize battery life, carefully study and follow the suggestions in this excellent guide to power reduction techniques.

Thank you, thus the configuration I should use in this case should be like in the picture?

Will 10 Ohm will be ok for the resistors?

muscionig:
Will 10 Ohm will be ok for the resistors?

If you want to measure μA you will get with 10Ω just ten times the value in μV. Have you tried to measure μVs with an Arduino?

Moreover the power consumption ist highly variable in time.

You might want to take a look here

You will count the mAh for e.g. 10h...

Will 10 Ohm will be ok for the resistors?

No, that won't work at all. See reply #1 and #3.

A possible solution is to use a INA226 Current sensing I2C module.
They are pretty cheap and give high side current measurement.
Library for an INA226.