Curitiba
2018
João Paulo de Melo
Matheus Eduardo Garbelini
Curitiba
2018
Abstract
The project consists of using new available wireless communication technologies applied to
energy monitoring in low voltage local area transformers. The hardware measures the voltage
and current of each phase of a 3-phase transformer, allowing to obtain energy quality parameters
like active, reactive, and apparent energy on each phase and on the overall system. Concepts of
signal processing and electrical power systems are applied in the embedded hardware in order to
provide the necessary behavior, informing when something in the measured transformer is wrong.
Lora/LTE communication is presented to be the main features to access the hardware remotely.
1 Introduction 7
2 Project Planning 8
2.1 Project Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.1 AC Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.2 Energy Meter Hardware . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.3 Analog Front-End . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.4 Processing Unity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.5 Local Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.6 Remote Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.7 Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 Project detailed description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.1 Main micro-controller . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.2 System Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.3 External communication interfaces . . . . . . . . . . . . . . . . . . . 20
2.2.4 Web User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.2.5 Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3 Printed Circuit Board Design . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.3.1 System Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.4 Risk Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.4.1 General Risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.4.2 Hardware Risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.4.3 Software Risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.5 Project schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.6 Software and tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3 Conclusion 38
References 39
7
Chapter 1
Introduction
Connectivity, undoubtedly, is the word of our century until then (2018). To share
something, perform the remote control of some device or to do the control/supervise something
remotely is becoming easier, cheaper and and widely used today. Even when we do not realize
that we are doing it, indirectly, we are sending or receiving something to/from someone. The use
of the Internet and other resources allowed us to carry out the supervision of a process remotely
to allow activities that were previously not possible.
Connecting things is the future. Even if that future is not too far away, there are still
many technologies to be developed. The use of smart meters that are capable of communicating
with a management center is another important tool in these innumerable connectivities that we
see in our daily lives and that can positively impact all the people involved. This device, thus,
can be seen as a tool capable of increasing efficiency and cost reduction by the companies that
use it and also impact the services used by the final consumer. It can be considered as one more
important tool in the revolution called Internet of things (IoT).
This project has a final goal of producing a hardware able to do electricity measurement,
anomaly detection and remote data sending to a management center using Lora or LTE
technologies. Our challenge and goal is in the search for new and alternatives technologies
that make our hardware technological, efficient, robust and more cost-effective compared to
preexisting technologies.
The following chapters are presented as the following: A description of the problem
involved in the project; Technologies that have a potential to be used in our final physical project;
The test procedures used to test and validate the component parts of the project; The risk analysis
of the main problems that we may face during development; The project schedule and finally a
conclusion pointing the principal project aspects.
8
Chapter 2
Project Planning
As discussed in other topics, the project goals is to provide not only the energy
measurement of a three phase power transformer but also to provide a simple and easy solution
to read those measurements through the use of remote connectivity. This is accomplished by
organizing the project in functional blocks which are described in the following subsections.
9
2.1.1 AC Sensors
In order to measure the higher electrical voltage and current flowing through the
three-phase power transformer, external current and voltage transducer sensors are used in this
step to ensure that next functional block will receive according low voltage signals.
• Frequency;
11
Most of the technologies chosen in the development of this project took into the
consideration of the principle of using electronic components, boards, modules etc., that meets
the technical needs, robustness, technology and costs. Since there are already some solutions on
the market in the application’s area of our device, we will seek alternatives, add new technologies
and always look for an optimized way to implement them - either by manufacturing new circuits
or purchasing existing modules.
Analog Front-End
We are studying the feasibility of using the ATT7022 (Figure 2.3) 3-phase electronic
energy metering chip. We are interested in this integrated chip because it is suitable for measuring
active power, reactive power, apparent power and reactive energy for each phase and 3 phases
combined; it is also suitable for measuring voltage RMS, current RMS, power factor, phase
difference, and frequency - that is, a wide range of things that demonstrate the quality of the
measured energy.
12
The big difference of this chip is the cost-benefit ratio. With the use of this, we will
reduce the cost, when compared to the solutions of meters already available in the market, and
we will have access to the quantities that we have interest. Other peripheral parts, such as the
sensors that will be used in the line of the voltage network, the entrance protection part and the
insulation circuit, among others, are in the process of being studied if it will be economically
interesting to acquire them in already ready modules or to make them according to our necessity.
Similar projects used this IC to provide solutions in intelligent energy metering solutions
as can be seen Xupeng e Xiu (2010) and Qi et al. (2015)
Alternatives to this chip exists such as ADE7868 form the ADE78XX series (Mhetre
et al., 2015) but they are at least 5 times expensive than ATT7022.
The main controller needs to be fast in order to receive and process the signals in real
time. Thus, Espressif devices could allow high performance with a reduced cost.
13
Due to the project requirement of being innovative, low cost and robust, Espressif’s
ESP32 (Figure 2.4) is used as the most viable option, it’s is very cheap compared to micro-
controllers of the same category (Cortex-M7 form STMicroelectronics) at around 5 dollars each
at current year of this paper. Furthermore, it includes WiFi that can benefit in development as it
support over the air upload and flexible boot-loader schemes. It’s also very successful in current
IoT application as can be seeing in Maier et al. (2017).
ESP32-WROVER module specifications are listed below:
• Integrated RTC;
The Schematic of the microcontroller unity is presented in Figure 2.5. U1 is the ESP32
itself (Figure 2.4). Other connections are organized as yellow labels and C2 and C3 are filter
capacitors for the MCU supply.
The jumpers K1 and K2 allows to select serial lines to be used for USB connection or
the IHM, as it’s optional.
To allow correct behavior of the MCU during supply startup, guarantee correct operation
under rough circumstances and some indication during development, the circuit of Figure 2.6 is
used.
14
The boostrap circuit is made of some resistors (R1-R3) that enables the MCU to correctly
power up. The external watchdog such as the U2 prevents the internal MCU to fail due to some
not planned internal software loops; the RTC Oscillator X1 enables the ue of the internal MCU
RTC and finally status LEDs D2 and D1 enables visual confirmation that the supply and MCU
are working.
16
Bootloader support
To fast development, there’s a need to use a bootloader. ESP32 MCU supports this by
deault in it’s main serial, but some external circuit must be used in order to interface with a USB
serial converter in order to reset and make the device enter in bootloader state automatically
without needing to reset the board. This can be shown in Figure 2.7.
The idea of the bootloader circuit is to whenever bootloader signals 0 and 1 are in zero
state, RST or GPIO0 will receive a 0V voltage. Fir instance, if and only if boot0 are in 0V,
GPIO0 will also be 0V. In contrast, if and only if boot1 is 0V, RST will also be 0V making the
esp32 reset. If the ESP32 resets and GPIO0 receives zero signal during some initial time, ESP32
will enter bootloader mode, thus allowing to received flash programs through the serial line 0
(UART0).
To capture energy measurements with a precise time stamp, a GPS can be used as can
be seen in the schematic of figure 2.8. The PPS signals allows the MCU to receive each second a
precise interrupt while the GPS Serial line sends NMEA messages so the MCU can know not
only it’s position but also it’s UTC Time.
17
The schematic of the battery charging circuit is shown in Figure 2.10. The CN3705
(U3) is a switched buck controller that allows to charge a multi cell battery as it allows to regulate
the maximum voltage that it charges.
Also a commom NTC sensor can be used alongside the battery via the connector J2 to
shutdown the charging process if an over temperature is experienced to the battery.
To allow maximum power transfer from the battery to the circuit, a perfect diode circuit
is used (M2, Q4A, Q4B).
19
The charging curve that the IC follows are depicted in Figure 2.10. Note that even tough
the graph indicate charging end at 4.2V, this can be adjusted for any voltage based on the feedback
resistors R12 and R14.
The bottom half of the charging circuit uses constant voltage comparators to detect if
the battery is low (U5, below 7.4V for 2 cell 4.2V batteries) and the type of the battery (U4, for
less than 6V batteries such as 2 series super capacitors). If the battery detected is less than 6V,
the Q3 transistor are enable, changing the feedback network so the maximum charger voltage is
around 5.5V.
Besides the SX1278 low cost, a variety of selectable base frequency modules from the
supplier can be bought. Furthermore, it’s a well tested device in IoT applications such as depicted
in Daud et al. (2018). The schematic of the module in this project can be seen in Figure 2.13.
LTE connectivity
The connectivity with a 4G/3G network can then be made with a USB modem such as
the ZTE MF823L 4G Modem (Figure 2.14). They are very cheap and can be found in national
market. It also supports external antennas to achieve better reception and transition.
Communication processor
It’s integration in the schematic is showed in the schematic of Figure 2.16. The connector
J5 is a 10 pin female header in which the OrangePi Zero is inserted above.
RS485
The use of a isolated RS485 IC is a must for a project involving power transformers as a
transient in the communication cable cannot damage the board. The commercial used for this is
the ADM2484 IC, which can be seen in the schematic of Figure 2.17.
23
For line termination, a 120Ohm resistor can be added by soldering the jumper J11; Dual
TVS D13 is used to protect the lines for voltages over RS485 levels (+12V/-7V) and an on-board
5V regulator U12 allows to use an isolated supply in order to communicate with the digital board.
USB
To allows easy hardware setup and programming, a USB is be included on the board.
As the onboard MCU doesn’t have a internal USB controller so an external serial-USB controller
ICs is be used such as the CH340C. The circuit can be seen in the schematic of the Figure 2.18.
USB protection is also included by using a bidirectional TVS D12 and a perfect diode
circuit which allows almost all the USB voltage to power the system and protect the USB against
reverse current.
24
The Nextion displays (Figure 2.19) is presented to be the best and cheapest solution to
integrate in this project as an optional interface that allows the user to configure some hardware
aspects.
25
A TTL serial interface is used to communicate with hardware or to program the display.
The HMI interface is programmed using a specialized editor (Nextion Editor) provided by Nextion
free of charge. It allows to simulate the user interface before deploying to the display itself via a
SD card integrated in the display.
Nextion also provides a lot of libraries to allow integration with the project hadware as
easy and fast as possible.
26
The web application development framework discussed above can also run as a native
desktop or mobile application. In the case of a desktop application NWJS enables web pages
to be executed as normal applications operational system like Windows, Linux or MacOS. It
uses an integrated chrome + NodeJS runtime to allow the page to also interact with the system
hardware like Serial Ports (Benoit, 2015).
Mobile applications can benefit from Cordova to run web pages as native applications.
It’s currently very popular and deeply supported by quasar framework in android, windows phone
and IOS smart phones (Brucker e Herzberg, 2016).
Measurement Graphs
In order to present a clean and easy to understand measurement information to the user
trough the web user interface, a javascript charting library such as High Charts is used (Figure
2.21).
High chart is very well know by the web community, it’s very reliable and easy to use
(Kuan, 2012).
27
The Web Server architecture is shown in Figure 2.23. The communication processor
(Orange Pi Zero) sends it’s local information through a private port that can only be accessed
through a VPN connection.
The LoopBack framework handles the logic between inserting new data using generic
access to a database such as MySQL. This API access can be made through normal API calls in
NodeJS.
The communication processor will also use LoopBack Framework for it’s interaction
with database, allowing a more robust access to configure the digital board and so on. A
configuration JSON file is used to store OrangePi configuration so it’s connectivity can be
configured.
29
to general project factors regarding this final year undergrate project; The second is related to
specific details about the type and complexity of an energy meter hardware proposed in this work.
A table containing a summary of all the listed risks and avoidance difficult is depicted
in Table 2.1.
• Components Supply: As this project involves the use of components that are not available
in the country of this project (Brazil), international components supplier alternatives
must be used. There are well knows companies such as DigiKey, Mouser, Farnell, LCSC
and RC Components. In order to avoid initial hardware development time, an supplier
must be chosen according to it’s arrival time and price.
• Printed circuit board: Most of the problems can occur in an initial prototyping stage of
the hardware. The use of inadequate or low quality printed circuit boards can affect
significantly the development time due to issues such as electrical issues on the board,
poor signal integrity, limited board options, etc. To avoid those problems, professional
printed circuit company must be used such as JLPCB, AllPCB, PCBWAY. Combined
with DHL courier as the shipping option, the board can arrive in maximum of one and a
half week.
• Project Complexity: There are 3 main system blocks in the project: Low voltage Energy
measurement, Hardware processing unity and local/remote LTE communication. In
each one there are specific critical details that if not followed would imply incorrect
or faulty behavior of the hardware. The project complexity is also product of how
much tasks are necessary to conclude each project part and how familiarized and skilled
are the students with the concepts and procedures involved contained in the project
development.
34
• Project cost: There is a maximum amount of resources available that can be spent in
development. Each development phase must agree with a maximum cost. This problem
consists of expenses in electronic components, shipping, software, PCB manufacturing,
manufacturing materials, sensors, modules, etc. Exceeding the maximum quota would
imply in not being able to conclude the project with integral hardware and functionalities.
The cost must always be aligned with each development step, choosing the only necessary
resources that will be used in order to achieve the goals.
• Low Voltage: The front end of the hardware must deal with voltages in the range of
110-240Vrms. Thus, must be developed solutions not only to support the specified
voltage limit, but also provide protection and suppression from electrical network surges.
Not being able to develop this solution would imply in damaging the hardware in a
possible transient scenario. In order to avoid this problems, guides and components
specifications must be followed.
• LTE Connectivity: Depending on the region in which the hardware is installed, internet
connectivity or bandwidth is not always guaranteed, even if dedicated receiver antennas
are used. In order to solve this issue, a third communication option must be used to
poll the energy metering data from the hardware. For instance, RS485 and Lora radio
communication could be added.
• Energy fault: There’s a risk that a electrical network measured by the hardware is turned
off intentionally or by some accident. If the hardware doesn’t detect this, faulty behavior
would occur in the measuring system. To avoid this issue, the main measuring integrated
circuit must provide some mechanism. This must be used as one of the main project
criteria for the components selection.
• Schematic and Layout validation: Besides the need of a correct and clean schematic
and layout project according to the project criteria’s, if a further validation step is
not done in early hardware step, the possibility in hardware faulty behavior that is
difficult to find such as incorrect pin placement, incorrect expected signals, incorrect
supply voltage. In order to avoid those problems or to at least help to identifying them,
montecarlo simulation must be done whether is possible and the schematic and layout
must additionally be organized in isolated blocks and include testing probes, jumpers
and extra components. This helps to better test the hardware when mounted and to
promptly identify the origin of a issue. Furthermore, with extra redundant components
included in the schematic, it gets easy to rework some circuit block for instance.
• Micro-controller peripherals support: There’s a common risk that even tough using
a micro-controller with initially all it’s available peripherals that the project needs, in
practice, an incomplete or faulty peripheral behavior is supported on software. To avoid
this issue in the micro-controller selection, the errata of it must be read and also official
forums must be searched to detect if anyone is having some problem or hardware conflict
in a specific peripheral and also if there’s a software workaround to use it normally
use. This present initially as low risk as can be done early in the project, but if for
some reason this step is overlooked, the consequences are catastrophic in later hardware
validation. Official sample codes for the targeted micro-controller also must be seen.
• Integrated circuit support: By using a dedicated integrated circuit to measure the energy,
a communication to the micro-controller is needed. To avoid development slow downs
in IC communication testing and configuration, sample codes from manufacturer must
36
be used as reference implementation. This also reduces the chance in generating bugs
that causes undefined behavior when reading or configuring the IC.
• Natural Docs: Used to generate documentation of all source code created in this project;
• Multisim, SIMetrix and PSpice: Allows the simulation of digital and analog circuits
behavior;
• WebStorm IDE: Web application development IDE that also enables remote debugging;
• RamNodes Webserver: The current project’s Virtual Privet Server used to test the web
server application frameworks and cutom linux kernel compilation if needed.
37
Programming languages
Currently, this project involves the use of programming languages (or auxiliary languages)
such as C/C++, Python (Maybe), Javascript, HTML, CSS and SQL. The authors of this project
also have experience or familiarity with this languages.
38
Chapter 3
Conclusion
The preparation of this report was extremely important for the organization of our work
project. With the realization of it, we had to search more about the subject and we had looked
for existing technologies in this field, to better understand the problem to which our solution
will be inserted. This was important also for a maturation of the idea of the project that we will
develop and a better collaboration with the involved students, since we had to discuss several
times, punctuate some things to reach some consensus.
It will be also a big challenge to meet the deadlines and the purchase of components
from international suppliers. For this to be achieved successfully, we observe that we will have to
work on our project with discipline, caution, respect for the time-line and anticipate things that
involve procedures that depend on other people or organizations: components imported as are
one example of it.
After completing this report, we have seen that it will be a great challenge. However, we
are motivated by our desire for optimization, implementation of new technologies in pre-existing
solutions and problem solving.
39
References
Daud, S., Yang, T. S., Romli, M. A., Ahmad, Z. A., Mahrom, N. e Raof, R. A. A. (2018).
Performance evaluation of low cost lora modules in iot applications. Em IOP Conference
Series: Materials Science and Engineering, volume 318, página 012053. IOP Publishing.
Leão, R. P. S., Sampaio, R. F., Antunes, F. L. M. et al. (2014). Harmônicos em sistemas elétricos.
Maier, A., Sharp, A. e Vagapov, Y. (2017). Comparative analysis and practical implementation
of the esp32 microcontroller module for the internet of things. Em Internet Technologies and
Applications (ITA), 2017, páginas 143–148. IEEE.
Mhetre, S. B., Kulkarni, H. H. e Bharadwaj, D. (2015). A simple and low cost solution for
measurement of harmonics in distribution sector. Em Computing Communication Control and
Automation (ICCUBEA), 2015 International Conference on, páginas 499–505. IEEE.
Qi, H., Gao, N. e Zhang, Y. (2015). Design of intelligent power supply unit based on zigbee
technology. Em 2015 International Conference on Education, Management, Information and
Medicine.
Saha, M. M., Izykowski, J. J. e Rosolowski, E. (2009). Fault location on power networks. Springer
Science & Business Media.
40
Shelby, Z. e Bormann, C. (2011). 6LoWPAN: The wireless embedded Internet, volume 43. John
Wiley & Sons.
Vasseur, J.-P. e Dunkels, A. (2010). Interconnecting smart objects with ip: The next internet.
Morgan Kaufmann.
Xupeng, C. e Xiu, J. (2010). Application of the wireless sensor network topology based on the
power acquisition system. Em Electrical and Control Engineering (ICECE), 2010 International
Conference on, páginas 2671–2675. IEEE.