Design and Testing of a Power Analyzer Monitor and Programming Device in Industries with a LoRA LPWAN Network

: Electrical installations represent an important part of the industry. In this sense, knowing the state of the electrical installation in real time through the readings of the installed power analyzers is of vital importance. For this purpose, the RS485 bus can be used, which most electrical installations already have. An alternative to the bus wiring and its distance limitation is the use of low-power wide area networks (LPWAN). The long range (LoRa) protocol is ideal for industries due to its low-power consumption and coverage of up to 10 km. In this research, a device is developed to control all the reading and programming functions of a power analyzer and to integrate the device into the LoRa LPWAN network. The power analyzer monitor and programming device (PAMPD) is inexpensive and small enough to be installed in electrical panels, together with the power analyzer, without additional wiring. The information collected is available in the cloud in real time, allowing a multitude of analysis be run and optimization in real time. The results support high efﬁciency in information transmission with average information loss rate of 3% and a low average transmission time of 30 ms.


Introduction
Nowadays, knowing the state of residential and industrial electrical installations in real time is of vital importance.The internet of things (IoT), together with the storage and analysis of data in the cloud, constitutes a fundamental tool for the monitoring of electrical installations.
Many electrical installations in industries are monitored locally with power analyzers that have RS485 bus connection capabilities but are not connected, and therefore measurements are not available remotely.Companies integrating with Industry 4.0 acquire a multitude of data from sensors, and thus measure a large number of variables, including electrical variables.Integrating power analyzers in expanded, modified, or new installations within industries requires wiring for the RS485 bus where measurements are concentrated.Even in this scenario, the measurements would be stored locally unless they were uploaded to the cloud from the control center.
The RS485 bus has a maximum length of 1200 m, reaching speeds between 300 and 19,200 bauds.This length may not be sufficient in many industries.In this sense, the use of wireless technologies would avoid the wiring and distance limitation.Low-power wide-area network (LPWAN) have ideal characteristics for the purpose of this research.
LPWANs include a long-range (LoRa) protocol with distances of up to 10 km in open environments and 5 km in closed environments, which is sufficient distance for the majority of installations.This research adopts LoRa as a wireless communication system for the implementation of a power analyzer monitor and programming device (PAMPD).This device is applicable to any power analyzer that works with the RS485 bus to integrate the data collection in the cloud and the programming of the device from the cloud.This research has the following structure.Related work is presented in Section 2. Section 3 describes the implementation of the PAMPD.The results of the research are detailed in Section 4.

Related Work
Security in communications, especially in industrial environments, is of particular importance today.Security is a critical challenge in the development and implementation of LoRa systems.Security must ensure that access to the network and information flowing through the system cannot be obtained by anyone.
In this sense, different authors have addressed the study of communications security in LoRa networks.Aras et al. [1] studied of the vulnerabilities and attacks to which LoRa networks can be subjected.Bhoyar et al. [2] reviewed the security challenges of IoT systems by observing energy consumption, security criteria, etc. Habibzadeh et al. [3] worked on safety plans in relation to sensors, actuators, and intelligent systems applied to smart cities. Radoglou et al. [4] analyzed the security of IoT systems in search of vulnerabilities and developed measures to mitigate the vulnerabilities found.Eldefrawy et al. [5] studied the security of long-range wide-area network (LoRaWAN) networks through a formal analysis to increase the security of this type of network.Kim et al. [6] developed a scheme to establish a communication link between devices.
To address the vulnerabilities of the LoRa network, it is necessary to develop secure systems with encryption to protect the information.Several works have been developed in this line of research.Kun-Lin et al. [7] developed an encryption system for communications in LoRa LPWAN networks using a 128-bit AES key.Xu el al. [8] studied the existing problem in the physical layer for the generation of security keys and implemented a secure method to generate the security key.Zhang el al. [9] worked on eliminating the existing correlation between security keys, obtaining a system to generate security keys applied to LoRa LPWAN networks.Kun-Lin et al. [10] designed a system that provides the security architecture for LoRaWANs with data encryption with AES encryption.Liagkou et al. [11] built a model to develop secure LPWANs with virtual reality.Sung et al. [12] created a secure location environment for IoT systems based on calculations with multiple sensors.
LoRa systems need to continue to advance, which requires the definition of new reference standards for the development of future security systems to increase the reliability of LoRa networks.This development is critical and difficult to resolve as it involves addressing complex security issues.Yugha et al. [13] conducted a study of the protocols and technologies related to the security in IoT systems to constitute a reference in the generation of future systems.Noura et al. [14] elaborated a review of security problems in LoRaWAN networks, identifying problems and offering action protocols to mitigate the identified problems.
The application of LoRa in smart cities and, by extension, in public electricity systemssuch as lighting systems, smart grids, etc.-requires defining lines of work that develop the security of LoRa systems in these environments.Bhattacherjee et al. [15] developed an architecture for use in LoRa systems implemented for public safety.
It is necessary to define standards, network architecture, and implementation protocols for LoRa industrial networks to serve as a basis for the implementation of these networks in Industry 4.0.Penkov et al. [16] implemented a LPWAN design for application in industrial environments, including network protocols and standards that allow the development of these networks.Rizzi et al. [17] applied LoRa wireless networks to industry 4.0 compared to previously used industrial wireless networks.Leonardi et al. [18] described the advantages that the MAC scheme provides for the application in industrial wireless networks.Mekki et al. [19] conducted a study to compare LPWAN technologies applicable to large installations where IoT devices are integrated.
Various industrial applications have been developed with LoRa networks.The electrical systems in industry, motors, outdoor lighting, high-voltage networks, etc. have been monitored.The use of these networks in industry is becoming more and more widespread due to their great possibilities.Cano-Ortega et al. [20] developed a smart meter prototype that integrates into LoRa LPWAN networks to monitor the efficiency of working conditions of induction motors used in industry.Sanchez-Sutil el al. [21] implemented an outdoor lighting system based on LoRa LPWAN protocol that can be used for the installation of outdoor lighting system in industries.Bonavolonta et al. [22] proposed an IoT system for industry 4.0 integrated into the Smart Grids for protection of medium voltage networks.Cano-Ortega et al. [23] developed a system based on wireless networks with cloud storage for power factor control in industry 4.0.Sanchez-Sutil et al. [24] implemented a smart meter for monitoring electrical consumption with a high resolution and sending data through wireless technologies and cloud storage.Hernandez et al. [25] studied the influence of granularity on measurements made with wirelessly connected smart meters.
In a wireless network, other major challenges-such as interference from installed equipment, electromagnetic noise, and signal coverage-need to be addressed.Elshabrawy et al. [26] worked with the limitations, noise in communications coverage, and interference considerations that can occur in a LoRa network.Zorbas et al. [27] worked with LoRa devices applied to an industrial building under industry 4.0.
It is essential to optimise the operation of the LoRa network, which is a major challenge for the definition of applications, optimization of configuration parameters, and adaptation of the network all in real time.Grufon et al. [28] implemented a prototype of a smart office prototype into a LoRa network in a teaching center.Raza et al. [29] studied the operating bases of the components integrated in a LoRaWAN for applications in industry 4.0.Cano-Ortega et al. [30] developed an ABC-based algorithm for the optimization of the configuration parameters of the LoRa LPWAN network in real time to achieve the best performance of the data traffic in real time with a minimum loss of information packets.Dawaliby et al. [31] studied the optimization of the spreading factor configuration parameter of the LoRa LPWAN network in smart cities. Spinsante et al. [32] conducted an experimental study to obtain a LoRa network design tool.For LoRaWAN networks, Loubany et al. [33] obtained an adaptive algorithm to select the spreading factor configuration parameter in networks with multiple gateways.
Power analyzers are essential equipment for monitoring the status of electrical installations, particularly in industry.This is due to the fact that the consumption that is produced is high, and interruptions in the service due to any type of failure imply losses for the company.Power analyzers help to identify these problems.Therefore, it is highly interesting to address the reading of data in real time.So far, and after a review of the stateof-the-art was performed, the integration of power analyzers in wireless LoRa systems has not been addressed.This research aims to address the automation and control of analyzers via the LoRa network.
In this research, and after reviewing the state of the art and previous works, the authors include a number of novel contributions:

•
A monitoring and programming device for power analyzers with no additional wiring.

•
Long data transmission distances, up to 10 km.

•
High-speed data transmission.

•
Reduced information loss rate.

System Architecture
The proposed system has two clearly differentiated parts: (1) LoRa LPWAN network and (2) WAN/Wi-Fi network.The first part is made up of all the PAMPDs and the PG1301 gateway concentrator.Communication is wireless using a LoRa protocol and bi-directional data flow.
The second network is established through communication with a WAN network, either wired or wireless, which connects the gateway and the IoT server (in our case, The Things Network (TTN) [34]).TTN can be connected to various IoT services such as Google Sheet [35], Google Firebase [36], Message Queue Telemetry Transport (MQTT) [37], IF This, Then That (IFTTT) [38], etc.Later, the information can be available on smart phones, computers, tablets, etc.These devices can display and/or store the measurements made, or they can send programming commands to the power analyzers.
Figure 1 shows the system architecture.

Hardware Design
The complete description of the hardware for PAMPD is provided in this section.To clarify the dependencies between the components of which the device consists, we present a block diagram that shows their relationships.The connection diagram allows the PAMPD to be constructed from the components used.Two features integrated into the design of the device are modularity and integration, which provide the device with a high level of tolerance to faults, with all functions not being out of service during repair.
The objectives for the development of PAMPD are as follows: • Reduced size: This is because the equipment has to be installed in the electrical panels where the power analyzers are arranged.

•
Reduced price: PAMPD must reduce the price to a minimum to ensure the viability of its installation in industries.

•
High reliability: Industries usually work on a 24/7 basis, so PAMPD has to be able to operate continuously with a low failure rate.

•
Fault tolerance and integration: PAMPD must be able to resume its functions after internal failure, power failure, etc.
On the other hand, the implementation of the objectives involves the following challenges:

•
Searching for components: It is necessary to study the different possibilities available on the market in order to make the right choice of components in the PAMPD.

•
Evaluation of alternatives: This is in order to achieve the most optimized system possible with high performance.
• PCB board design: This is to integrate the selected components adequately and in the minimum dimensions.

•
Modular design: This is so that the PAMPD has a high level of fault tolerance.

Components
Before describing the hardware of PAMPD, it is necessary to present the relation of the components used so that the characteristics of each one of them are known.These include microcontrollers, wireless communication (LoRa), and RS485 bus communication.

Microcontroller
A microcontroller is composed of several components (microprocessor, memory, digital and analogical inputs and outputs, communication ports, etc.) that can be used to perform a variety of tasks through programming for industrial and domestic applications.The microcontrollers that work in free and open-source programming are especially interesting.This environment allow sharing solutions with the community of developers.The integration with peripherals that extend the capabilities of the microcontroller is another interesting feature.
In this sense, the Arduino platform has all the characteristics previously mentioned, giving a great potential for the development of industrial and domestic devices.Another important aspect is the size of PAMPD and is integrated within an electric panel; therefore, the size is decisive in the design of this device.
To evaluate the choice of the PAMPD microcontroller, Table 1 shows the characteristics of the models from the Arduino family.The prices shown in Table 1 are for official Arduinos.Compatible Arduinos are available at much lower prices.The characteristics of the memory, clock speed, and microcontroller are sufficient for this application.Therefore, in this case, the size is the most decisive feature to achieve the objectives proposed in the PAMPD design.Of all the Arduino family microcontrollers, the Arduino Nano (AN) (Arduino AG, Ivrea, Italy) was chosen as the core of the device developed due to its great features and small size.Its characteristics make it ideal for the purposes of this research.The characteristics of the AN can be found in [39].

LoRa Wireless Communication Chip
The LoRa LPWAN network plays a fundamental role in the system that was developed.It is the basis of communication and information exchange between the power analyzers and gateway for the control and monitoring of the electrical panels.In a LoRa LPWAN network, several devices send information to a gateway that concentrates a large amount of devices (some models more than 1000).After receiving the information from the different PAMPDs, PG1301 (Dragino Technology Co., LTD., Shenzhen, China) sends the information to the cloud.There are commercial gateways from different manufacturers, such as Dragino, which offers different solutions: (1) LoRa gateways [40], (2) LoRa concentrator [41], and (3) LoRa GPS HAT [42].
Table 2 shows the characteristics of the gateways considered.From the data in Table 2, we can conclude that the LoRa concentrator has the best features since it allows up to 1000 devices to be connected at the same time and has 10 communication channels.Another added feature is that it runs on Raspberry Pi (Raspberry Pi, Cambridge, UK) from model 3 onwards, meaning that additional software can be installed.The network optimization algorithm proposed by Cano et al. [30] is implemented on Raspberry.
In this investigation, we decided to use the Dragino LoRa concentrator PG1301 (Dragino Technology Co., LTD., Shenzhen, China) mounting in a Raspberry Pi 3 B (Raspberry Pi, Cambridge, UK) in order to adapt to the needs of the proposed system.PG1301 can be integrated in a maximum of 1000 LoRa devices.
Table 3 shows the comparative characteristics of the LoRa components analyzed.This shows the parameters that influence the selection of the component used in the PAMPD.
As can be seen in Table 3, the characteristics of the LoRa devices are similar.In terms of power consumption, Monteino, Libelum, and DLB have a lower power consumption.The smallest size is Motenino, followed by Libelium and DLB, which are presented in Bee format.The lowest price is that of DLB, far ahead of the others.
Due to the similar performance of the different elements available, other aspects are taken into account to choose one over the other, such as their integration with other components (AN, RS485 bus).We chose the DLB due to its reduced size and high performance, making it ideal to integrate within the proposed system.
Price, size, and consumption also have to be taken into account.In this respect, DLB offers the best features of the analyzed products.

RS485 Bus Communication
In order to be able to control all the readout and programming functions of the power analyzer, a component is required that allows the AN to send commands and receive data via the RS485 bus.The protocol used is MODBUS.
The integration with the RS485 bus, together with Arduino, has many components that act as an interface for both systems, among which it is worth mentioning the following: (1) RS-485 Digilent 410-310 (Digilent, Austin, Texas); (2) C25B-MAX485 (Maxim Integrated, San Jose, CA, USA); (3) Shield RS485 (DFRobot, Shangai, China) of DFRobot; and (4) Shield MKR 485 (Arduino AG, Ivrea, Italy).The DFRobot RS485 shield is designed to be used with Arduino Uno, Arduino Mega, etc.Therefore, it requires a model with dimensions larger than AN.The MKR 485 shield needs an Arduino of the MKR family, which has dimensions closer to AN, but have high performance and higher cost boards.
Table 4 shows a comparison of the RS485 components analyzed.MAX485 has been chosen for the designed device because of its reduced dimensions, reduced cost, and good performance for the developed application.The main features of the MAX485 are presented in [54].

PAMPD Hardware Implementation
The design of PAMPD is based on AN, which concentrates the interaction of the LoRa network with the power analyzer.Thus, the AN receives messages from the LoRa network to read information or program the power analyzer.The AN then sends the information from the power analyzer to the LoRa network so that it is available in the cloud.
Within the WPAN networks (wireless personal area network), we find Bluetooth, Zig-Bee, and Wi-Fi, which have a range of coverage from a few meters to 100 m approximately.Unfortunately, this coverage does not make it useful in medium and large industries.Within the WLAN (wide local area network), we have SigFox, Nb-IoT, 4G-5G, and LoRa.SigFox is a proprietary system, and a contract with the distributor is required.Nb-IoT and 4G-5G need a SIM card with a data contract in each of the devices.Therefore, they are less viable options.
The LoRa network is part of the low-power consumption, which guarantees a very low power consumption in the devices working under this network.In another sense, LoRa has a coverage of up to 10 km in open places and approximately 5 km in closed places.These distances make it ideal for use in industries of any kind due to its great coverage.Additionally, it only needs a network connection at the gateway, which reduces the system costs.The network chosen in this work was a LoRa LPWAN.
To understand the relationships between components within the PAMPD, a block diagram is shown in Figure 2. In the diagram you can see the data flows between components, the voltage relations and the connection for programming.The electrical connections between the components are shown in Figure 3.An electronic board has been constructed from the connections to integrate all the components.Power is supplied by a 230 VAC to 5 VDC power supply and a maximum current of 500 mA.The actual prototype was developed and implemented on an electronic board.Figure 4 shows the PCB board design.In Figure 5, the assembled PAMPD with all the components installed can be seen.The design objective of a small size was achieved.The dimensions are 50 mm wide by 80 mm long.These small dimensions allow the PAMPD to be integrated into an electrical panel.Achieving a low-cost device is essential, so that its massive implementation in industries is viable.To this end, Table 5 shows the approximate cost of the components, materials, electronic board, and container box.

Software Design
The PAMPD must run a program that allows all the functions for which it has been designed.Figure 6 shows a flow chart describing the program.
In order for the PAMPD to work correctly, a series of initial processes must be performed to allow access to the communication systems.In this sense, the serial port for communications with the RS485 bus must be initiated through MAX485 and the LoRa system to send and receive messages with the network.
As long as the PAMPD has power, it works continuously.The flow of the PAMPD starts with a scan of the network for new messages.If a message is received, it must check whether it is a data reading or a power analyzer programming message.If the message is a read message, the corresponding command is sent to the power analyzer, and a response is expected.Once the response is received, the information is sent to the gateway using the LoRa network, and the network scan is returned.When the message received is a programming message, the command is sent to the analyzer, and it returns to the network scan.

Results
To test the operation of the PAMPD, the results section shows the operation of the device under different conditions.The electrical machine control panel located in the electrical machine laboratory of the Department of Electrical Engineering at the University of Jaen (Andalusia, Spain) was used.Each of the tests lasted 30 min, and alternators, motors, and loads were used under a variety of test conditions, which are discussed in the following sections.In addition, the LoRa network parameters were measured to evaluate the network's performance.

Case Study-Test Equipment
The PG1301 gateway was in the laboratory of high voltage installations, located on the ground floor of the A3 building of the Higher Polytechnic School of the University of Jaén.The PAMPD was inside this same building, on the second floor, in the electrical machine laboratory.
The high voltage laboratory's height is equivalent to two floors due to the distances required for the high voltage tests that are performed in this laboratory.Therefore, there are actually three floors of difference between the two laboratories.The vertical distance is 20 m, as the height of each floor is 5 m.Horizontally, the gateway and PAMPD have a distance of 12 m between them, which leads to a distance of 23.32 m.
Figure 7 shows the distance between the PAMPD and the gateway so that the existing obstacles are clearly identified.As there are no excessive distances, any of the available combinations of bandwidth (BW), code rate (CR) and spreading factor (SF) can be used.A BW of 500 kHz, CR of 4/5, and SF of 7 were chosen for this test, which ensures the fastest transmission speed and a lowest packet loss rate (PLR).We obtained these values by applying the optimization algorithm of the LoRa network presented by Cano-Ortega et al. in [30].The data were taken every 5 s.This parameter is configurable according to the measurement needs.
In the following sections, the characteristics of the equipment used in the tests are explained, which has been divided into power analyzers, electrical machines, and loads.

Power Analyzer
Five Circutor brand power analyzers were installed in the electrical panel.The CVM96 model (Circutor, Barcelona, Spain) with RS232 communication protocol was used to measure the parameters of the complete panel, which is connected to the PAMPD via a RS232-RS485 converter.Each alternator had two CVM-NRG96 power analyzers (Circutor, Barcelona, Spain), one with a RS485 connection and one without one.On the other hand, there was a CVM-B100-ITF analyzer that was not integrated in the switchboard so that it could measure the electrical variables of equipment not monitored in the switchboard.Figure 8 shows the location of power analyzers in electrical panel.Each model has different measurement capabilities.Table 6 shows the main electrical variables that each of the analyzers was capable of measuring.

Electrical Machines
Four electrical machines were used in the tests: (i) synchronous alternator; (ii) asynchronous motor with a squirrel-cage rotor connected to the generator and to the mains; (iii) asynchronous motor with a wound rotor connected to the generator and to the mains; and a (iv) dynamo brake to put load on the motors.The main characteristics of the electrical machines are shown in Table 7.In order to work with the generator, the brake dynamo and loads connected to the grid.Three loads were used: (1) 4 kW Langlois RH40 resistive load (Langlois, Mira Loma, CA, USA); (2) 6 kVAr Langlois LH60 inductive load (Langlois, Mira Loma, CA, USA); and (3) 6 kVAr Medelec CCT-002-128 capacitive load (Medelec, Zejtun, Malta).The power of the loads was appropriate to the power of the electrical machines to which they were connected.Table 8 shows the features of the loads.

Measurement Tests
The tests were performed in two separate parts, the first with the alternators and the second with the connection of elements to the grid.The tests conducted on the analyzers were as follows:

•
Connected to the grid • Feeding a three-phase squirrel-cage rotor motor • Feeding the three-phase wound rotor motor • Feeding to three-phase loads The following tests were conducted on the connection of different elements to the grid: • Three-phase squirrel-cage rotor motor • Three-phase wound rotor motor • Three-phase loads

Grid-Coupled Synchronous Generator
In the grid-coupled test, the alternator was coupled to the grid to increase the energy produced.The 4 kW asynchronous engine was used as the driving machine, whose power was sufficient to drive the alternator at its maximum power generation speed.Within 30 min of the test, the engine's torque was modified to vary the generation.The test schedule can be seen in Table 9.

Time (min)
Motor Torque (Nm) Additionally, Figure 11 shows the measurements made in the LoRa system.Data on frequency, channel number used, receive signal strength indicator (RSSI), signal noise ratio (SNR), packet loss rate (PLR), and time on air were acquired.Since gateway and PAMPD are located in Europe, the frequency used was 868 MHz. Figure 11 shows LoRa network measurements.When changing the channel, the PG1301 concentrator moved in the range of 867.1 to 868.5, corresponding to channels 7 and 0. Therefore, PG1301 used right channels for communication during the duration of the test.The RSSI signal intensity moved between −70 dBm and −80 dBm during the test.This signal intensity was complemented by an SNR sensitivity between 6.5 dBm and 11.5 dBm.Values that produce good communication and a low PLR rate were between 1.85% and 2.15%.The time on air it ranged between 45.18 ms and 25.49 ms.
The alternator was connected in wye because the line voltage in three-phase systems in Spain is 400 V, and the alternator has a voltage ratio of 230/400 V.The results obtained are reflected in Figure 12, which shows the data of phase voltages, currents, active power, reactive power, power factor, and current harmonics from 2 to 15.
The results shown in Figure 12 were obtained with a CVM-NRG96 analyzer, which was connected to the alternator output on the panel.As it can be seen, the voltages are between 236 V and 242 V. Considering the currents in Figure 12b, the variation in torque produced by the engine regulation is clearly reflected, directly influencing the current with a range of variation between 1.9 A and 2.95 A. The effect of making a change in the motor control can also be seen in the power and power factor graphs.
Current ammoniums, except for 3, remain almost stable at a maximum of around 2%.However, ammonium 3 has the highest content and is clearly affected by the test variation, with values between 6% and 13%.

Synchronous Generator Feeding a Three-Phase Asynchronous Motor with a Squirrel-Cage Rotor
The generator was connected to the other 4 kW squirrel-cage asynchronous motors available in the laboratory.The test schedule is shown in Table 10.During the first 5 min, the motor was stopped and then restarted and run without a load to finish in a 20-min cycle in which the torque varied from 0.5 Nm to 2 Nm.

Time (min)
Motor Torque (Nm) No load 5 0.5 5 1.0 2.5 1.5 2.5 2.0 2.5 1.0 2.5 0.5 Figure 13 shows the measurements of the LoRa network.As can be seen, frequencies between 868.5 MHz and 867.1 MHz were obtained using the channels 0 to 7. The intensity of the RSSI signal varied by 6 dBm, between −47 and −53 dBm, with a sensitivity in the range of 5.5 dBm to 11.5 dBm.
The PLR for this test was between 2.8% and 3.2%, with an average time on air of about 20 ms and a peak of 95 ms.
Figure 14 shows the result of the tests performed.The motor was wye connected wye.The generator also used the same connection so that both machines had the same 400 V voltage level.The current graph (Figure 14b) clearly shows the evolution of the test, which is also reflected in the active power graph (Figure 14c).For the reactive power the motor has a more constant evolution once started.The power factor moves between 0.8 and 0.9 when the engine is started and under load and behaves worse when not opposed to torque.As in the previous case, the harmonic with higher is the third, with heat around 20% when the engine is started.With the engine stopped, the harmonic with higher content is the second with values above 80%.

Synchronous Generator Feeding a Three-Phase Asynchronous Motor with a Wound Rotor
This section is complements previous one performed on the asynchronous motor with a squirrel-cage rotor.In this case, the motors were exchanged by connecting the wound rotor motor to generator, which has similar characteristics.Since the characteristics are similar, the same test planning was done, as shown in Table 11.LoRa network measurements reflect the use of the same channels as for previous cases, channels 0 to 7, with a frequency range from 867.1 MHz to 868.5 MHz.As for RSSI, the range was between −47 dBm and −53 dBm and SNR between 6 dBm and 11.9 dBm.These were similar values to those obtained in previous tests.The PLR in this case was between 2.7% and 2.9%, lower than in the previous test.On the other hand, the time in the air remainder in the interval of 27 ms to 31 ms with punctual peaks that reached 41 ms.Data can be seen in Figure 15.The motor in this case was connected in a wye.The current in this motor was somewhat higher than that of the squirrel-cage rotor, reaching values close to 2 A, 0.4 A higher.However, the active power was lower with a maximum of 200 W, as opposed to 300 W in the previous case.This is due to a lower power factor in this case, which only reached values of 0.8 for the maximum test speed.
The harmonics in this case had lower values than the previous engine, with maximums at a load speed of around 10% for harmonic 3, and a much lower value of the remaining current harmonics.Figure 16 shows the results obtained in the test.

Synchronous Generator Feeding a Three-Phase Load
To complete the tests with the generator, a resistive and an inductive load were connected to the output of its terminals.The planning of the test is reflected in Table 12.The first half of the test was done with a resistive load that varied between 90 and 210, and the second half with an inductive load that varied between 0.38 H and 0.9 H.As can be seen from the measurements of the LoRa network shown in Figure 17, the channels and frequencies are the same due to the use of the same gateway.RSSI varied in this case from −47 dBm to −53 dBm, with SNR between 6.5 dBm and 12.8 dBm.For this test, a PLR range of between 3.7% and 4.3% was obtained, associated with an average time in the air of 28 ms, with peaks of 46 ms. Figure 18 shows the result of the test.The highest current consumption occurs with the resistance of 90 Ω, reaching 2.5 A (Figure 18b), with powers up to 500 W and 500 VAr (Figure 18c,d).For the current harmonics, the highest harmonic is the third with an average of 6% and peaks close to 10%.The loads were connected in wye.

Three-Phase Asynchronous Motor with a Squirrel-Cage Rotor
To conduct this test, the squirrel-cage motor was connected to the mains and its behavior was measured.The test sequence is shown in Table 13.The first test was carried out with the motor without load in order to progressively add load until 8 Nm was reached.

Time (min)
Motor Torque (Nm) The channels used by the gateway were the same as in the previous cases; therefore, the frequencies are also the same.The range of the RSSI signal moved between −47 dBm and −53 dBm.In this case, the SNR sensitivity moved in the range of 6.8 dBm and 11.9 dBm.The measurements yielded a PLR of between 3.4% and 3.6%, with an average time on the air of 28 ms and peaks of 55 ms.The data is shown in Figure 19.The current measurements (Figure 20b) were between 3 A and 5.3 A, with active powers between 200 W and 1000 W. The reactive powers were between 670 VAr and 560 VAr.In this case, the most important harmonics corresponded to 2 and 5, the latter being higher with a maximum value of 4%. Figure 20 shows the result of the tests.The motor in this case was connected in a delta.

Three-Phase Asynchronous Motor with a Wound Rotor
The wound rotor motor was subjected to the same test regime as the squirrel-cage motor since they have similar power ratings.The same test allows a comparison of the different behavior of the motors.Table 14 shows the schedule of the test.As in previous cases, the gateway worked with the same channels, 0 to 7, which means that the same frequencies between 867.1 MHz and 868.5 MHz were used.It is also possible to observe (Figure 21c,d) that there is a signal intensity and sensitivity within the ranges shown in previous cases.In this test, RSSI was obtained between −47 dBm and −52 dBm and between 6.5 dBm and 11.6 dBm for the sensitivity.The PLR interval was between 4.5% and 4.7%.The time ion air was around 29 ms on average, with peaks reaching 49 ms. Figure 21 shows the measurements of the LoRa.
The motor was connected in wye for this test.Figure 22 shows the result of the measurements performed.In this test, current readings between 2.8 A and 3.7 A average were achieved.These currents involve an active power between 200 W and 600 W and a reactive power between 660 VAr and 590 VAr.It is possible to observe how the power factor evolves between 0.25 and 0.7.The highest harmonics for phases 1 and 3 was number 3 with a maximum of 3% and 3.7%, falling to 1.5% and 2%, respectively, at the end of the test.On the other hand, Phase 2 presented a higher harmonic content in #5 with values between 1.8% and 1.1%.Order also had high values close to order 5.

Three-Phase Load
For testing the loads connected to the network, a parallel RLC configuration was set up, where the values of each type of load were varied.Table 15 shows the values applied to the loads in each 5-min stage.As the location of the gateway and the PAMPD remain unchanged, the channels and frequencies used are the same as in previous cases.The variation intervals obtained for RSSI and SNR were from −47 dBm to −53 dBm and 6.5 dBm to 11.9 dBm, respectively.The PLR moved between 2.64% and 2.95%.Finally, the time on the air was an average of 29 ms, with peaks not exceeding 49 ms.Measurements taken in the LoRa network are reflected in the Figure 23.The current measured in this test had higher values than those obtained in previous tests, reaching values close to 10 A for intervals 3 and 6.In parallel with the current behavior, the active power behavior had maximum values reaching 2250 W. The most pronounced ammonium was of order 2, with maximum values of 20% and minimum values of 2.5%.These were much higher than the rest of the harmonics shown.The loads in this case were connected in wye. Figure 24 shows the results of the test.

Cloud Storage
In Section 3.1, several IoT services were presented where the measurement information could be sent from TTN server specially designed for LoRa LPWAN IoT systems.As an example of use in this section, we show the uploading of information to Google Sheets using LoRa and TTN.To do this, you first must have a TTN account, which is easily achievable.Then, you must register the gateway and create an application for the project by adding the device.
Then, within the application, an integration is created.In this case, the option is 'HTTP integration'.This is where the address of the previously created Google Sheets sheet is introduced.The data received by TTN from the PAMPD will automatically be sent to Google Sheets.

Conclusions
This research develops a low-cost device for the integration of power analyzers into wireless networks under the LoRa protocol and RS485 interface.The PAMPD has a low cost that allows its installation in industries.The main advantages of the PAMPD are the following: (i) low cost; (ii) small size; (iii) long transmission distances; (iv) low rate of information loss; and (v) high transmission speed.
The monitoring of the readings and the real-time programming of power analyzers constitute a fundamental tool in the control and optimization of electrical installations within industry 4.0.Having information in real time, through the use of the cloud, makes it possible to improve the operative performance of electrical systems installed in industries.
The use of the LoRa LPWAN wireless network makes it possible to achieve a highpowered communication system.It is possible to automate the power analyzers from small to large industries due to the distance coverage of up to 10 km that can be obtained in LoRa networks.This, together with the fact that up to 1000 devices can be integrated into the LoRa concentrators, means that the number of network elements, costs, and installation and maintenance and repair times are reduced.In addition, the PAMPD is small enough to fit easily into the space available within the electrical panels.
The results obtained support the design of the PAMPD.In this sense, PLR is very low with an average of 3%, which minimises information loss.The time on the air is small, of the order of 30 ms on average, which ensures the rapid transmission of information.Moreover, the results are available in the cloud in real time, which allows great flexibility in the analysis of the information and the necessary actions that could be taken in the electrical installation.Storage in the cloud can be performed with different services according to the criteria and needs of each user.The above results are a guarantee of the PAMPD's performance.The information generated and the control orders can be visualised and sent from many devices, such as computers, smart phones, tablets, etc.
The PAMPD has the ability to connect to LoRa network, monitoring and programming power analyzers, improving the capability of industries to monitoring and have data in cloud with no additional wiring.

Figure 1 .
Figure 1.Architecture of the proposed system.

Figure 2 .
Figure 2. Hardware block diagram of the power analyzer monitor and programming device (PAMPD).

Figure 7 .
Figure 7. Section of the A3 building showing the obstacles between the PAMPD and gateway.

Figure 8 .
Figure 8. Electrical panel located in the electrical machine laboratory.

Figures 9 and 10
Figures 9 and 10 show the wiring diagram of the CVM-NRG96 and CVM96 power analyzers inside the electrical panel for a better understanding of how the installation was done.

Figure 9 .
Figure 9. Wiring diagram for connecting the PAMPD with the CVM-NRG96 power analyzer into an electrical panel.

Figure 10 .
Figure 10.Wiring diagram for connecting the PAMPD with the CVM96 power analyzer into an electrical panel using RS232/RS485 converter.

Figure 25
Figure25shows a screenshot of the data received at TTN, and Figure26shows the data sent to Google Sheets.

Figure 25 .
Figure 25.Data uploaded to The Things Network (TTN).

Figure 26 .
Figure 26.Data uploaded to TTN and sent to Google Sheet.

Table 5 .
Power analyzer monitor and programming device (PAMPD) components cost.

Table 6 .
Main electrical variables and communication protocol of power analyzers.

Table 7 .
Features of the electrical machines.

Table 8 .
Features of the loads.