Make Your Own Power Meter/Logger

80,158

490

47

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

5 People Made This Project!

Recommendations

  • Tape Contest

    Tape Contest
  • Arduino Contest 2019

    Arduino Contest 2019
  • Trash to Treasure

    Trash to Treasure

47 Discussions

0
None
DerekA46

Question 7 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!

3 answers
0
None
Chiranjiv_sc30DerekA46

Answer 27 days ago

Hey can I get a copy of the entire code?.I would like to compare it with mine for rectifications.??

0
None
DerekB103DerekA46

Answer 2 months ago

HI DerekA46,

Did you ever work out the 1V issue? I have just created the power meter in last day or two and have exactly the same issue. If I manage to work it out (with my limited coding and electronics ability) before I hear back from you, I'll post a reply here.

Else, if you already have the answer, I'd appreciate knowing!

Thanks.

0
None
DerekB103DerekB103

Reply 2 months ago

So, with a little bit of thought and watching the video again, I was able to work out the 1V issue ... and it really makes simple sense.

In the video, when he mentions when connecting the testing load and source, that you connect the positive lead of the source to the Vin+ of the INA219, you connect the Vin- to the positive terminal of the load, and then you connect the negative terminal of the load to the GND of the measuring device (the Arduino). Obviously, I had to connect something to the negative end of the source or the load wouldn't draw any current(there would be no complete circuit), so I thought that's what he meant ... connect the negative terminal of the load to the negative end of the source.

What he actually means is, connect the negative terminal of the load to the negative end of the source AND the GND of the measuring device. You have to connect it to BOTH. Without a connection to the GND of the Arduino as well as the negative of the source, you cannot measure a true Voltage drop and so, the display only ever shows 1V.

That fixed my 1V issue rioght away!

0
None
mlhanes

Question 4 weeks ago on Introduction

How can this project be adjusted to monitor higher wattage useage like with appliance? I would like to build this to monitor copier power useage and perhaps spikes.

0
None
mlhanes

Question 5 weeks ago on Introduction

Can this project be used to monitor a larger piece of equipment like for instance a copier?

0
None
DerekB103JabinS1

Answer 8 weeks ago

Yes, it can.

The "load" will be whatever you are connecting to your panels, whether a battery to store your energy or some device you are powering. The "source" will be your panels. All you need to do is, more or less, connect this device between your panel and your device/battery.

0
None
EthanB98

Question 2 months ago

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

1 answer
0
None
DerekB103EthanB98

Answer 8 weeks ago

All you need to do is, more or less, connect this device between your panel and your device/battery.

The "load" will be whatever you are connecting to your panels, whether a battery to store your energy or some device you are powering. The "source" will be your panels.

0
None
sagiro

Question 7 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?

1 answer
0
None
DerekB103sagiro

Answer 8 weeks ago

Yes, it can.

The "load" will be whatever you are connecting to your panels, whether a battery to store your energy or some device you are powering. The "source" will be your panels. All you need to do is, more or less, connect this device between your panel and your device/battery.

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 2 months 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
martinezJ2

2 months ago

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

0
None
BHRAMOSk

Question 3 months 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
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.

1 reply
1
None
NathanS213Lofty1960

Reply 8 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.