{'fraction_non_alphanumeric': 0.02578268876611418, 'fraction_numerical': 0.011808038132380023, 'mean_word_length': 4.925545571245186, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
IoT Based Building Energy Monitoring and Controlling System Using LoRa Modulation and MQTT Protocol

Building energy monitoring systems are carried out to facilitate the monitoring and controlling of building energy consumption. Monitoring and controlling the use of electrical energy in real-time in a building has an impact on the pattern of regulating the efficiency level of energy use. This paper presents an effort to optimize energy consumption by using an energy management system using LoRa modulation and MQTT protocols. Sensors that feed electrical power data to a custom energy monitoring system are compiled by a set of sensors equipped with a power supply that is fastened to the system on a microcontroller with a LoRa communication interface then are called nodes. The nodes consist of arduino uno as a microcontroller, dragino LoRa Shield, ACS712 current sensor, ZMPT101B voltage sensor, and relay. Dragino LoRa Gateway LG01-N is used to connect the measured parameters to the IoT cloud server. MQTT protocol is used for the broker between nodes and servers using subscribe and publish method. In the initial experiments, the data visualization platform used was the open-source thingspeak platform. This platform includes a data visualization template and enables device control for savings. In the end nodes, the voltage, current, and power sensor accuracy error are 1,24%, 2.60%, and 3.13%.


Introduction
According to the Agency for the Assessment and Application of Technology (BPPT), electricity demand in Indonesia is projected to increase more than six times from 226 TWh in 2017 to 1,471 TWh in 2050 [1]. In 2017, more than 88% of electricity in Indonesia was produced from fossil fuels such as coal (65%), gas (18%), and oil (5%). Only 12% of the total electricity production in Indonesia comes from renewable energy sources. As fossil energy that cannot be renewed, fuels such as coal, gas, and oil will be increasingly reduced availability which results in an increase in electricity rates.
Based on the 2018 Electricity Statistics data from the Ministry of Energy and Mineral Resources Republic of Indonesia, Indonesia's largest electricity consumer is from the household sector with a figure reaching 41.69% of the total electricity production in the country [2]. The high level of consumers from the household sector indicates that efforts must be made to save electricity usages.
Monitoring electrical energy and control the electrical equipment can be a way to optimize the electricity usages. Along with the development of the Internet of Things (IoT) energy-saving measures will be increasingly easy to do. IoT is defined as a network that is not only able to connect objects, automate, collect, send and process information intelligently but also can realize science management anytime and anywhere through sensing devices and the internet [3]. Therefore, in this works the design of an IoT-based energy monitoring and controlling system will be carried out which has a function for monitoring electrical power and control electrical equipment using smart power outlet.
Research on IoT-based energy management has been conducted by several other researchers. Among them is a study by Tui-Yi Yang [4] where the author designed a smart home energy management system (HEMS) that is able to analyze electricity usage and the history of all household appliances used and the results obtained are schemes made able to control energy costs used by smart way of monitoring household electricity conditions. Mohammed Abo-Zahhad [5] designed an energy management system (EMS) consisting of Arduino Uno, Xbee-PRO ZigBee module, ACS712 sensor, and NI LABVIEW software. The result is that EMS can reduce energy consumption during peak loads and thereby reduce carbon emissions. In Yatharth Gupta's research [6] an energy management system was designed in the form of real-time load monitoring and forecasting the required load, energy source management, and overcurrent protection and load automation with IoT. Khwanchai Oversight [7] developed an IoT device for monitoring energy consumption in a building. The device uses the PZEM-004t electric energy sensor, the Arduino Nano microcontroller, and the ESP8266 serial-to-Wi-Fi board. As a result, the device can work well and is able to collect energy data that is useful for efficient energy management. Haithem Chaouch's research [8] designed heating, ventilation, and air conditioning (HVAC) system which was implemented to control and monitor energy consumption in buildings using fuzzy logic, machine to machine communication (M2M) and internet technology. The system is designed to reduce energy consumption automatically. In Hyeonwoo Jang's research [9], a system using mixed reality technology was created. Mixed reality technology is a technology that creates a virtual world by combining reality with virtual information through interaction. This research is projected to develop an integrated energy management system in a smart city.

Sistem Design
The design of this system uses LoRa Gateway -Wi-Fi communication. Where LoRa stands for Long-Range is a unique and awesome modulation format created by Semtech. Modulation generated using FM modulation. The core in processing produces a stable frequency value. The transmission method can also use PSK (Phase Shift Keying), FSK (Frequency Shift Keying), and others. LoRa was chosen because it has several advantages including low power consumption, low data rate, and wider range [10]. As for the protocol used in internet, communication is the MQTT Protocol. MQTT (Message Queuing Telemetry Transport) is a protocol that runs on the TCP / IP stack and is specifically designed for machine to machine (M2M) communication. MQTT was chosen because it can send data faster with limited resources. Monitoring parameters include power usage and the number of electricity bills. This system uses two end nodes and one gateway. Each end node consists of Arduino Uno as a microcontroller, Dragino LoRa Shield is a link to the gateway, ACS712 current sensor and ZMPT101B sensor to read current and voltage, and also relay module to control the load to be controlled. The gateway type for this work is Dragino LG01-N Single Channel 915MHZ LoRa Gateway. It suitable for Indonesian frequency. To display data from sensor readings and control features, one of the IoT server / MQTT Broker clouds, which is Thingspeak on a computer and the MQTT Dashboard application on Android. The system architecture is shown in the Figure 2.

Result and Discussion
Testing is needed to know the accuracy of the energy monitoring system. The tests are enforced by measuring current, voltage, power, and the average value of error. The error means the deviation value of sensor compare the multimeter. Measurements and calibrations are carried out repeatedly to get the lowest error value.

ZMPT101B Voltage Sensor Testing
Testing the voltage sensor are executed by comparing measurements on the sensor and digital voltmeter for several times. The aim is to get the best value of accuracy. The test was carried out with five experiments. After testing the voltage sensor the test results are obtained as shown in Table 1.

ACS712 Current Sensor Testing
Testing the current sensor by comparing measurements on the sensor and digital voltmeter for several times and various load. The aim is to get the best value of accuracy. The test was carried out with five experiments. After testing the current sensor, the test results are obtained as shown in Table 2. The error value is calculated by summing all measurement data and divided by the number of measurements (times). Therefore, based on table 1, the error value is 2.60%.

Power Measurements
Power is calculated by the real power equation, which is the multiplication of effective voltage, effective current, and power factor. The effective voltage and current can be taken from table 1 and table 2. While the power factor is taken from the average power factor promised by the national electricity provider that is equal to 0.8. The results of the power calculation are shown in the following table 3. The error value is calculated by summing all measurement data and divided by the number of measurements (times). Therefore, based on table 1, the error value is 3.13%. The results of testing the accuracy of the voltage, current, and power calculations indicate that the accuracy of the sensor is high. This means that this measurement system is feasible to use.

Conclusion
This work is designed to function to measure and control voltage, current, power, energy, and electricity bill from a single-phase power line in a building using LoRa modulation. This device is a low-cost IoT device consisting of two electric energy sensor modules, a microcontroller, a LoRa-wifi communication module, and a gateway. IoT devices are used to collect data to support efficient energy management and are proven to function well because they produce reliable data smoothly.

Acknowledgement
This work was supported by PNBP Research Grant from Universitas Sebelas Maret. We would like to thank to Internet of Things (IoT) Laboratory Faculty of Engineering Universitas Sebelas Maret.