Вы находитесь на странице: 1из 5

Digital Energy Meter

Emir Salihagi
Electrical and Electronic Engineering (MA)
Faculty of Engineering and IT, International Burch University
Sarajevo, Bosnia and Herzegovina
emir.salihagic@stu.ibu.edu.ba

Abstract Energy meter is a device that measures the amount of


electric energy consumed by a residence, a business, or an
electrically powered device. Electric utilities use electric meters
installed at customers' premises to measure electric energy
delivered to their customers for billing purposes. They are
typically calibrated in billing units, the most common one being
the kilowatt hour [kWh]. This type of digital power meter can be
used to store measured data periodically and then to do statistical
calculations and pattern recognitions with now most popular
method Machine learning algorithms.
Keywords energy; power; arduino; tiva launchpad; power
meter; energy meter; bluetooth communication;

learning algorithms needs to have high frequency


measurements, which are usually made from 0.5 10 seconds.
B. MAX471 B43 Module
Module can be used to test the current and voltage. The
principle of voltage test based on principle of resistive voltage
divider design, can make the input voltage to 5 times smaller.
Arduino analog input voltage is up to 5V, the voltage detection
module input voltage can go up to 25V, and if using 3.3V
systems, input voltage can go up to 16.5V. Arduino AVR chips
have 10-bit ADC, so this module simulates resolution of
0.00489 (5V/1023), from that we know that the minimum input
voltage detection module is 0.00489*5=0.02445.

I. INTRODUCTION
Digital energy meter was made in four parts. First part is
connecting MAX 471 B43 Module for measurement of current
(I) and voltage (V) to the Arduino Uno R3 development board.
Power and energy measurements will be made at Arduino Uno.
Second part of the project is to implement wireless Bluetooth
communication between Arduino Uno R3 and Tiva C Series
TM4C123G. Third part of the project is to display data from
Tiva C Series TM4C123G to the Nokia N5110 LCD. In this
project Arduino Uno R3 is used to read measurements from
sensor and to send it to the server (Tiva C Series TM4C123G)
over wireless Bluetooth communication. Fourth part of the
project is to do testing and see is the whole system working
correctly.
A. Requirements
Requirements for making Digital energy meter were:

Use MAX 471 B43 Module for measurements

Make communication between Arduino and server


wirelessly with range up to 8 meters

Measurements and calculations are made every


second

Use sensor which can measure up to 50 W

Send power calculations every second to the server

Figure 1 Arduino and MAX471 B43 Module Connections


Parameters:

Test Voltage range: DC 3-25 V (Arduino work on


5V) or DC 3-16.5V (Arduino work on 3.3V)

Test Current range: DC 0-3V.

After finishing the device, I will check if I meet all


requirements. Timing is important because this device, if meet
its time requirements, can be used for making measurements
which can be used into Machine learning algorithms. Machine
Figure 2 MAX471 B43 Module Pinout

GND: All of the grounds are connected to the same


electrical point
VOUT: Connects the high side of your load
VIN: Connects to the positive pole of your voltage source
(This can be anywhere from 3 to 25 Vdc)
AT: Provides 0 to 5V signal that is scaled to 1V to Arduino
analog input for every 1A sensor measured. (e.g. for 2A read it
sends 2V to analog pin AT_PIN (A1) on the Arduino)
VT: Provides a 0 to 5V signal that is scaled to 1V to Arduino
analog input for every 5 Volts input measured by sensor (e.g. for
2V read it sends 0.4V to analog pin VT_PIN (A0) to the
Arduino)
C. HC 05 Wireless Bluetooth Module
In this project I need two Bluetooth modules, and I am using
two HC 05 wireless Bluetooth modules because they can work
as master and as a slave. They can be easily configured thought
serial monitor on the Arduino IDE software. Figure 3 shows how
to connect Arduino Uno and HC-05 wireless Bluetooth module.

2.2. In the Arduino IDE, go to the Tools\Serial Monitor


menu
2.3. The two following settings are correctly set (at the
bottom right of the window):
2.3.1. Line ending should be set to Both NL & CR
2.3.2. Baud speed should be set to 9600 baud
2.4. When the Arduino is reset (opening the Serial Monitor
dialog will force a reset) you should see the following
text Enter AT commands: in the Serial Monitor
dialog.
2.5. Press the key on the HC-05 Bluetooth module and
connect the power wire (5.0V) on the HC-05. Now red
light should slowly be blinking (once every ~2
seconds)
2.6. In the Serial Monitor, type AT and press Enter (or
click the Send button). The module should return OK
right away, if you set everything correctly up to now.
2.7. In the Serial Monitor, type AT+ROLE=0 and press
Enter. This will set the module in Slave mode. You
can verify that it worked by typing AT+ROLE? (It
should return +ROLE:0)
2.8. In the Serial Monitor, type AT+BIND= and press
Enter. This will remove any existing binding. You can
verify that it worked by typing AT+BIND? (It should
return +BIND:0:0:0)

Figure 3 HC-05 Bluetooth Module wiring on the Arduino


Uno

2.9. In the Serial Monitor, type AT+ADDR? and press


Enter. This will return the MAC address of this HC05 module. For example: my module's address is 00:
2016:1:66659 and the command is returning
+ADDR: 2016:1:66659. As you can see the zeros
are stripped out and the formatting is a bit different.
Write down on a piece of paper this MAC address.
2.10. Disconnect the power wire from the HC-05. It is now
ready to act as the Slave module.

Wiring:

HC-05 GND --- Arduino GND Pin

HC-05 VCC (5V) --- Arduino 5V

HC-05 TX --- Arduino Pin 10 (soft RX)

3.1. Make sure the power wire (5.0V) is disconnected from


the HC-05

HC-05 RX --- Arduino Pin11 (soft TX)

3.2. Make sure the Key wire is connected to pin 9

HC-05 Key --- Arduino Pin 9

3.3. In the Arduino IDE, go to the Tools\Serial Monitor


menu

D. Set up HC-05 Bluetooth modules as master / slave


To set up both HC-05 wireless Bluetooth modules follow
steps are required:
1. On the Arduino it is important to upload needed code for AT
commands. [2]
2. Using one of your 2 HC-05 Bluetooth module, follow very
carefully the wiring instructions written above (in step two
we are setting up slave):
2.1. Make sure the power wire is disconnected from the
HC-05.

3. Using second HC-05 Bluetooth module, follow same wiring


instructions as in step 2.

3.4. The two following settings are correctly set (at the
bottom right of the window):
3.4.1. Line ending should be set to Both NL & CR
3.4.2. Baud speed should be set to 9600 baud
3.5. Press the key on the HC-05 Bluetooth module and
connect the power wire (5.0V) on the HC-05. Now red
light should slowly be blinking (once every ~2
seconds)

3.6. Connect the power wire (5.0V) on the HC-05. You


should see the red light slowly blinking (once every
~2 seconds)

DC -> PD_2

3.7. In the Serial Monitor, type AT and press Enter (or


click the Send button). The module should return OK
right away.

LIGHT-> PF_4

3.8. In the Serial Monitor, type AT+ROLE=1 and press


Enter. This will set the module in Master mode. You
can verify that it worked by typing AT+ROLE? (It
should return +ROLE:1)
3.9. In the Serial Monitor, type AT+BIND= 2016,1,66659
and press Enter (of course here you should be using
your MAC address that you have noted on step 2.9).
This will force the Master module to automatically
link (bind) to the Slave. You can verify that it worked
by typing AT+BIND? (It should return +BIND:
2016:1:66659)

RST -> PD_1


This display can write char values on it, so if you have
some other variable you need to convert them to the char. My
variables are float because of precision in calculation, and I am
converting float to string and then string to char.
II. SOFTWARE AND HARDWARE
After the whole preparation is done and sensor, Bluetooth
and LCD are connected to boards we need to set up our software
according to the flowcharts that I made.
A. Software Structure
Software which I am going to make need to make
measurements at the Arduino Uno and to send power
calculations to the server which is Tiva C Series TM4C123G.

3.10. Disconnect the power wire from the HC-05. It is now


ready to act as the Master module.
Now if you power both modules, they will connect right
away. It doesn't matter if you power one before the other one.
They will always initiate the connection automatically.
E. Nokia 5110 LCD
The Nokia 5110 is a basic graphic LCD screen for lots of
applications. It was originally intended for as a cell phone
screen. This one is mounted on an easy to solder PCB.
It uses the PCD8544 controller, which is the same used in
the Nokia 3310 LCD. The PCD8544 is a low power CMOS LCD
controller/driver, designed to drive a graphic display of 48 rows
and 84 columns. All necessary functions for the display are
provided in a single chip, including on-chip generation of LCD
supply and bias voltages, resulting in a minimum of external
components and low power consumption. The PCD8544
interfaces to microcontrollers through a serial bus interface.

Figure 5 Flowchart for Arduino Uno R3 software

Figure 4 Nokia 5110 LCD


For controlling Nokia 5110 LCD on the Tiva C Series
TM4C123G I am using Ada Fruit Library. Because I am using
this library there is pinout which need to be connected:
CE -> PD_0

Important part of Arduino UNO R3 software is


measurements over analog inputs for voltage and current and
calculating the power. Total energy is expressed in the mWh
(mili Watt hours) because this digital power meter is used for
small energy loads. Variables i and j variables are for
measuring time. Variable i is used for current seconds and
variable j is previous second. I need both because of
measuring average power.

CLK -> PA_2

power = voltage * current;

DIN -> PA_5

avgpower = ((avgpower*j)+power)/i;

totalenergy = (avgpower*i)/3.6
It is important to multiply measured voltage with 5.0 because
of the scaling which is made by sensor.

After getting float power value to Tiva C Series TM4C123G


(server) it is important to divide it by 1000. It was multiplied on
the Arduino by 1000 because of the precision while wireless
communication is in progress. As I mentioned it before it is
important to convert all values to char if they are not char already
before the writing them to Nokia 5110 LCD, which is supporting
char values.

Figure 6 Arduino Serial Monitor


Total energy is calculated in mWh. From the Arduino Uno I
am just sending value for power to server (Tiva Launchpad), but
there are all calculations made on the Arduino Uno because of
checking what is displayed on Nokia 5110 (calculations from
Tiva) and calculations made on Arduino Uno which can be seen
at the Arduino IDE Serial Monitor.
Figure 8 Digital Power & Energy Meter
III. EXPERIMENTAL VALIDATION
In video which is presented we can see that current power is
shown around 0.491W. According to calculation Current will be
98.2mA. And for blue colored diode in the datasheet [3] on the
internet I found that maximum current is around 100mA.
Data transfer validation is also done. Both devices are turned
off. Then Tiva (server) was first plugged on the power and then
Arduino Uno. Both devices are showing same current power and
total energy that is used.
All values are transferred from Arduino Uno to Tiva
Launchpad and written to display every 1 second.
IV. RESULTS
At the end of this project all hardware requirements (sensors,
LCD, development boards and wireless communication) are
met.
Arduino can communicate to server wirelessly up to 10m, in
requirements it was written up to 5m. That information can be
found in the HC-05 Bluetooth module, where it is written that
Bluetooth is working up to 10m.

Figure 7 Flowchart for Tiva C Series TM4C123G software

Voltage precision in measurements on the sensor is


24.45mV. Calculated power which is in W is divided by 1000
before transmission over Bluetooth, because of this precision to
not lose it.
.

ACKNOWLEDGMENT
I would like to thank to my family for endless support in my
education.
Special thanks of gratitude are expressed to my professor
Assist. Prof. Dr. Tarik Uzunovi for his help and advices while
working on this topic.

REFERENCES
[1]
[2]

[3]
[4]

Arduino. http://www.arduino.cc.
Modify The HC-05 Bluetooth Module Defaults Using AT Commands,
http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-ModuleDefaults-Using-A/step2/The-Arduino-Code-for-HC-05-CommandMode/
Led Specification, http://ledz.com/led.datasheet/05W580BBC.pdf
TivaC Series TM4C123G LaunchPadEvaluation Board, 2013. EKTM4C123GXL Datasheet,
http://www.datasheetlib.com/datasheet/345772/ek-tm4c123gxl_ti-texasinstruments.html#datasheet.

Оценить