let's say you have an awesome gadget
that uses a USB connection to charge its
battery year or simply uses USB power
directly to work properly in both cases
a so-called USB power meter can be
useful tool to measure the voltage of
the USB port the current your gadget
draws the power it does needs and most
importantly it also locks how much
energy is transferred this way after
converting the value to kilowatt hours
you can simply multiply this value with
the price per kilowatt hour and
therefore for example calculate that
wireless charging a smartphone
cuz you 0.15 U or more for every 100
charges now of course you can get such a
power meter for cheap on eBay but in
this video I will show you how to create
your own portable upgraded version which
has a wider voltage range a higher
measuring frequency and even SD card
support in order to evaluate your
measurements later on let's get started
an Arduino Nano will be the brain of the
organization for the first prototype
measuring voltage bovitz
is as simple as connecting the positive
terminal of your loads to analog inputs
the negative terminal to ground and
writing a simple analog read commands
but measuring current is definitely a
bit more complicated commonly you will
need a current shunt which is basically
a precise low value resistor that needs
to be placed in series to your loads in
order to create a voltage drop
proportional to the flowing current this
voltage drop can then be amplified and
fed into a microcontroller in order to
calculate the current value but in order
to make life easier for us let's simply
use the I n a 219 bi-directional current
power monitor I see I got mine embedded
on a PCB year for only $2 from eBay
which also includes a supposedly zero
point 1 ohm current
and a screw terminal due to the maximum
current shunt input voltage of 320
millivolts we can measure a maximum
current of 3.2 amps and a maximum
voltage of 26 volts hooking up the IC to
the Arduino is the same procedure as
with any other I squared C device serial
data connector a4 and C you a clock
connects a5 at this point we could use
the wire library of the arduino to write
our own ice query codes in order to
communicate with the IC but we could
also just download the i na 219 library
from Adafruit included and write wait
fewer lines of codes in order to output
the current and load voltage through the
serial monitor in order to measure
anything useful though we first need to
connect the v+ pin to the positive
terminal of the supply voltage the me-
pin to the positive terminal of the
loads and the ground of the loads to the
ground of the measuring system now the
serial output levels pretty accurate
values which means we can continue by
using three more variables and the
moolies function in order to that the
measurement repeat every 100
milliseconds this way I cannot only add
a power measurement outputs by
multiplying the current and load voltage
but also an energy counter which adds
the power value multiply it by 100
milliseconds converted into hours to the
previous energy value since the serial
monitor now presents all the values we
care about correctly it was time to add
a display to the circuits in this case a
0.9 6 inch OLED LCD which I got from
eBay for $4 the wire ring was exactly
the same as before
since the LCD also uses the I squared C
communication protocol after downloading
and including the library for it from
Adafruit it was simply a job of using
the print light function and figuring
out where to position the text on the
LCD in order to make it look decent and
for many people this setup should
already fulfill the demands for power
meter but not for me that is why I got
myself a commonly available
SD card PCB which can be found for $2
and also includes the lvc 125 level
shift I see this I see is important
because the SPI pins of the Arduino 11
to 14 to which the SD cards needs to get
connected to have a high voltage level
of 5 folds but the SD card can only
handle 3.3 volts and don't worry if you
miss the step during the wiring of those
components because I utilized the EZ EDA
free circuit design software to create
an appropriate schematic before hands
you can find a link to it along with
other project information as always in
the video description now after
formatting the SD card and plugging it
in we could use the SD library which is
always included in the Arduino IDE in
order to write to it but I have to say
that had quite a few problems with its
while trying to open the files I rather
recommend the SD fat library which uses
the same commands but does function
without a problem with its the SD card
create three text files which contain
the time voltage and current values by
simply importing them into a program
like Excel you can then create
decent-looking graphs and of course also
calculate the power and energy values
last but not least I remove the used
components from the breadboard replace
the Nano with an ultra no pro mini which
are programmed within FTDI break ouch
added a lipo battery both protection /
charging circuit to the system so load
everything onto a piece of perf boards
and connected the components to one a
novel of course you can create a
beautifully crafted enclosure for your
power meter but mine doesn't really need
one for what I have in mind for it and
with that being said this project is
completes and works like a charm I hope
you liked this video as always don't
forget to Like share and subscribe stay
creative and I will see you next time