Make Your Own Power Meter/Logger

75,818

484

39

About: Awesome Electronics Tutorials, Projects and How To´s

In this project I will show you how I combined an Arduino, an INA219 power monitor IC, an OLED LCD and a Micro SD Card PCB in order to create a power meter/logger that has more functions than the popular USB Power Meter. Let's get started!

Step 1: Watch the Video!

The video gives you a good overview on how to create your own power meter. In the next steps though I will present you some additional information to make this project even simpler.

Step 2: Order Your Parts!

Here you can find a parts list with example seller for the portable version of this project.

Amazon.com:

1x LiPo Battery: http://amzn.to/2gz4yvd

1x TP4056 Board: http://amzn.to/2gzdIb4

1x Arduino Pro Mini: http://amzn.to/2gvfXuQ

1x INA219 Board: http://amzn.to/2gvflW7

1x OLED LCD: http://amzn.to/2fobopO

1x SD Card PCB: http://amzn.to/2fodhmu

1x Switch: http://amzn.to/2gz9ZtW

Ebay:
1x TP4056 Board: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x Arduino Pro Mini: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x INA219 Board: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x OLED LCD: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x SD Card PCB: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

1x Switch: http://rover.ebay.com/rover/1/711-53200-19255-0/1?...

Amazon.de:

1x LiPo Battery: http://amzn.to/2gM2vXB

1x TP4056 Board: http://amzn.to/2eUvMNO

1x Arduino Pro Mini: http://amzn.to/2g6Ujjr

1x INA219 Board: http://amzn.to/2gM5M9v

1x OLED LCD: http://amzn.to/2g6Q3Rd

1x SD Card PCB: http://amzn.to/2gM9Zdf

Step 3: Create the Circuit!

Here you can find the schematic for the Arduino Nano version and the portable version of this project. You can also find those schematic on the EasyEDA website:

https://easyeda.com/GreatScott/PowerMeter-b6051723...

https://easyeda.com/GreatScott/PortablePowerMeter-...

You can also use the pictures of my finished board as a reference for your own.

Step 4: Upload the Code!

Now that your circuit is complete, it is time to upload the code. You can download it here. But don't forget to download and include the following libraries before uploading:

https://github.com/adafruit/Adafruit_INA219

https://github.com/adafruit/Adafruit_SSD1306

https://github.com/greiman/SdFat

Step 5: Success!

You did it! You just created your own Power Meter/Logger


Feel free to check out my YouTube channel for more awesome projects:

http://www.youtube.com/user/greatscottlab

You can also follow me on Facebook, Twitter and Google+ for news about upcoming projects and behind the scenes information:

https://twitter.com/GreatScottLab

https://www.facebook.com/greatscottlab

4 People Made This Project!

Recommendations

  • Paper Contest

    Paper Contest
  • Warm and Fuzzy Contest

    Warm and Fuzzy Contest
  • Remix Contest

    Remix Contest

39 Discussions

0
None
smooth_jamie

2 years ago

Hi there, nice project. I'm curious as to what the lowest measured current is possible on this project and what the accuracy is?

3 replies
0
None
smooth_jamieGreatScottLab

Reply 2 years ago

Done what you've suggested, datasheet gives ADC resolution, and accuracy (fair enough), but doesn't really answer the first part of my question. I'd like to know with regards to the way this is setup, what is the lowest current you have managed to measure? A approximate idea would be very helpful.

0
None
pingouin_smooth_jamie

Reply 16 days ago

Hello,

Full scale shunt voltage is 40mV (for PGA /1). Depending on the Rshunt value you select, you might get quite low on measured current...

0
None
EthanB98

Question 20 days ago

How do i use this to measure 9V 3W solar panels?

0
None
martinezJ2

22 days ago

is it normal that i have in voltage 32,72 Volts ??

0
None
BHRAMOSk

Question 5 weeks ago on Step 2

I am from india and the LiPo battery isnt ship to India. Is there any alternative and can i use 6V D.C. battery.

0
None
DerekA46

Question 5 months ago

So I know this have been here a while but I have a few questions,

1. How to do you modify the code so it only records an input measurement every 10min? [Figured this out... a few coding changes and it works like a champ. I had to seperate out the unsigned long interval for the reading measurements and unsigned long interval for the display readings.

for future reference if you want to change the time between reading measurements saved to the SD card the code should read like this:


updated code:

unsigned long previousMillis = 1799910; // this number is set to take a reading when program starts
unsigned long interval = 1800000; // interval time between data recording Set in milliseconds.
unsigned long previousMillisDisp = 0;
unsigned long intervalDisp = 100; // interval time between LCD refresh Set in milliseconds.

const int chipSelect = 10;
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
float energy = 0;
File TimeFile;
File VoltFile;
File CurFile;


void setup() {
SD.begin(chipSelect);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
ina219.begin();
}

void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
previousMillis = currentMillis;
ina219values();

TimeFile = SD.open("TIME.txt", FILE_WRITE);
if (TimeFile) {
TimeFile.println(currentMillis);
TimeFile.close();
}

VoltFile = SD.open("VOLT.txt", FILE_WRITE);
if (VoltFile) {
VoltFile.println(loadvoltage);
VoltFile.close();
}

CurFile = SD.open("CUR.txt", FILE_WRITE);
if (CurFile) {
CurFile.println(current_mA);
CurFile.close();
}
displaydata();
}

if (currentMillis - previousMillisDisp >= intervalDisp)
{
previousMillisDisp = currentMillis;
ina219values();
displaydata();
}
}

***Everything else within the code should remain the same.***

2. I am trying to measure the voltage and current drop of a battery operated LED light string... I can get the correct current to be displayed but no matter what I do the circuit will only display 1V. What am I doing wrong?

Thanks again for your help and this is a great setup!

0
None
sagiro

Question 5 months ago

Hello,

I wanted to know if there is a way to turn it into a solar panel tester to know how much energy I can get from the cell in various places around my house and find the best place to position the panel.
Can this do what I'm asking?

0
None
Lofty1960

1 year ago

Hi Great Scott and all,

WHen compiling code I get this error. I am using Pro Mini, Arduino IDE 1.6.13 and the librabies that are listed on this site.

Any help would be appreciated.

Sketch uses 22,302 bytes (72%) of program storage space. Maximum is 30,720 bytes.
Global variables use 2,216 bytes (108%) of dynamic memory, leaving -168 bytes for local variables. Maximum is 2,048 bytes.
processing.app.debug.RunnerException: Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#si... for tips on reducing your footprint.

2 replies
1
None
NathanS213Lofty1960

Reply 6 months ago

A bit late, I know, but I was having the same issue and realised that the screen uses up a lot of memory. I'd previously updated Adafruit_SSD1306.h to select the 128x64 screen, but I notice Scott has the 128x32 screen configured - this uses half the memory and allowed the program to compile. With only 2K of SRAM to work with you have tp save space where you can I suppose.

0
None
Lofty1960NathanS213

Reply 6 months ago

Hi Nathan

All working now, thanks for your support.

Regards

Lofty

1
None
NathanS213

6 months ago

If anyone is running out of memory while compiling, make sure to tell the OLED library that you're using a 128x32 pixel screen - you get the double-size text but it only uses 512 bytes SRAM compared to 1024 bytes used by the 128x64 configuration.

This is achieved by editing the Adafruit_SSD1306.h library file (assuming you're using that library) and ensuring it is configured for 128x32 by defining SSD1306_128_32 instead of SSD1306_128_64.

1 reply
0
None
Lofty1960NathanS213

Reply 6 months ago

Hi Nathan,

Brilliant thanks for update.

I'll go back to this one and try again.

0
None
PoojaP38

Question 10 months ago on Step 2

can this circuit measure ac voltage and current for live ac loads

1 answer
0
None
mbrock1PoojaP38

Answer 9 months ago

If you are talking about live AC in the sense of household wiring then no. It has a maximum voltage of 26VDC. Depending on location your mains voltage will be ~110VAC or 220-240VAC.

Also the INA219 is a 'High Side DC Current Sensor' and as such will only reliably measure DC currents.

0
None
FarrelRam

Question 9 months ago

Hi, i have a problem to upload the arduino code,

"Adafruit_SSD1306-master/Adafruit_SSD1306.h:49:26: fatal error: Adafruit_GFX.h: No such file or directory"

1 answer
0
None
mbrock1FarrelRam

Answer 9 months ago

You will also need to install the Adafruit_GFX library. It can be found on GitHub or also conveniently in the library manager.

0
None
AlrickH

Question 11 months ago

hi, congrats and thanks for a great video. I want to make a similar project but i need to monitor more current like upto 24 volts and 21 Apms.......what you suggest i do, or replace in the your given circuit? Hope to get a quick reply.

0
None
Tribalus

11 months ago

Great project! I'm building my one as of this moment.

I just have 3 questions to make:

- Does the circuit functions well when the battery level gets lower? Would it be better too use a booster to push the voltage to somewhere around 5V?

- How would you implement a battery level checker?