Laura García
email: laugarg2@teleco.upv.es

Jose M Jimenez

Jaime Lloret
email: jlloret@dcom.upv.es

Pascal Lorenz
email: lorenz@ieee.org

WiFi and LoRa Energy Consumption Comparison in IoT ESP 32/ SX1278 Devices

Keywords: Energy consumption, battery life, WiFi, LoRa, transmission power. I

The use of Internet of Things (IoT) devices has spread through many different fields. Transport, health, and energy management of farming are some of the areas where IoT systems are being utilized. The selection of the wireless communication technology for the IoT system is paramount for its optimal performance. However, factors such as desired coverage or energy consumption must be considered for this selection. In this paper, several tests to determine the battery life that can be obtained after performing WiFi and LoRa Low Power Wide Area Networks (LPWAN) transmissions with a low-cost IoT device has been performed. With a 5 second transmission interval and default settings, similar results were obtained for both WiFi and LoRa. Furthermore, WiFi outperformed LoRa with the default settings and a 30 second transmission interval. Lastly, LoRa did outperform WiFi when the settings where changed so as the transmission power of LoRa was that of 10 dBm.

INTRODUCTION

Currently, IoT devices are used in a wide variety of areas. According to IoT Analytics [START_REF]The 10 most popular Internet of Things applications right now[END_REF] the areas where IoT was most used in 2018 are Smart homes, Wearables, Smart Cities, Smart grids, Industrial internet, Connected cars, Connected Health (Digital health / Telehealth / Telemedicine), Smart retail, Smart Supply chain and Smart farming. In order to improve the performance of the implanted systems, it is necessary for the results observed by the sensors to be sent to other systems. The processing and storage capacities of IoT devices are generally very limited. Usually, in the case of wanting to correct an error or wanting to optimize the performance of the observed elements or environments, after processing the data, the appropriate corrective measures are taken to optimize the observed functions. To transmit the information, which is captured by the sensors connected to the nodes, both wired and wireless technology are used depending on the ease of installation of the physical infrastructure in the observed areas.

In a large number of cases, the sensors used to monitor the IoT devices need to establish a wireless communication to transmit the observed data. Garcia et al. [START_REF] García | Wireless Technologies for IoT in Smart Cities[END_REF] presented a review of wireless technologies that were employed in Smart cities, their comparison and the problems that make their coexistence difficult.

One of the areas in which the use of wireless technology becomes more evident is in Smart farming. Currently, it is very difficult to connect IoT devices that are located in large tracts of land through a wired network. In addition, when using agricultural machinery, which is often heavy vehicles, it is very difficult not to deteriorate or break the copper or fiber optic wires deployed in the fields. It is very easy for situations to appear where the tools attached to the vehicles can drag the cables. For this reason, Smart farming is one of the ideal areas where wireless technology should be used. Aspects such as foliage density, which can change according to the seasons or depending on the growth state of the plant, should be considered as they can affect the wireless transmission. These types of smart systems for agriculture monitor parameters such as irrigation, the humidity and temperature of the soil or the environmental conditions.

There is a wide range of wireless technologies, among which we can highlight those that comply with the IEEE wireless standards such as IEEE 802.11 [START_REF]GET 802(R) Standards[END_REF], IEEE 802.15 [START_REF]GET 802(R) Standards[END_REF], and IEEE 802.16 [START_REF]Broadband Wireless MANs[END_REF]; we also find mobile technologies such as 3G [START_REF]The Mobile Broadband Standard. About 3GPP[END_REF], 4G, 5G. In addition, we can find other proprietary technologies such as LoRa [START_REF] Alliance | [END_REF], NB-IoT [START_REF]Standardization of NB-IOT completed. 3GPP A Global Initiative[END_REF], and Sigfox [START_REF]Sigfox, a 0G Network[END_REF].

In some situations, it is necessary to use a large number of sensor nodes. Obviously, the cost of the nodes, if they are used in large numbers, can be prohibitive. In addition, if mobile technologies are used to establish transmissions, such as 4G or any other, the cost of the node is significantly increased, and maintenance is also expensive. Furthermore, it would be necessary to hire the services of a mobile operator that has coverage in the space that will be monitored.

We have observed that inexpensive nodes that include wireless technologies are available on the market. Among the most currently employed we can find nodes that include IEEE 802.11n interfaces, Bluetooth Low Energy (BLE) and LoRaWan.

One of the main problems that we found when implementing a solution is the energy consumption of the nodes. If the nodes remain active in real time, to know at any moment the parameters that are considered necessary, they will consume a large amount of energy. Assuming that the nodes are distributed in dispersed locations, where it is not possible to bring the energy at reasonable costs, the supply of electrical power can become a big problem. Depending on the needs of different crops, the observation time may vary, but if the difference in energy consumption of the nodes is based fundamentally on the employed wireless technology, our interest is focused on selecting the most appropriate technology, so that energy consumption is minimal.

For all the reasons described previously, we have carried out some tests to identify which of the two wireless technologies considered in this paper can be used in such a way that it extends the transmission capacity as much as possible, provided that the transmitted data are identical. In our work we have studied WiFi and LoRaWan technologies, which are supported by our sensor nodes.

The rest of the paper is organized as follows. Section 2 presents the related work. A background in WiFi and LoRa technologies is presented in Section 3. The testbed is explained in Section 4. Section 5 depicts the obtained results. Lastly, the conclusion and future work are presented in Section 6.

II. RELATED WORK

In this section, the related work on energy consumption studies for WiFi and LoRa is going to be presented.

When selecting the communication technology for an IoT deployment, the energy consumption is one of the most considered factors. Several papers focus on determining the energy consumption of LoRa and WiFi.

Ayele et al. [START_REF] Ayele | Leveraging BLE and LoRa in IoT Network for Wildlife Monitoring System (WMS)[END_REF] performed a simulated comparison of the energy consumption of BLE and LoRa in a Wildlife Monitoring System. The authors proposed a dual radio network model. The nodes were deployed on the collars of the animals. The communication between the nodes was performed over BLE until it reached a cluster head. Then, the cluster head communicated through LoRa to a Lora gateway. The energy consumed by the LoRa star topology increased as the nodes increased, due to the overhead. However, the proposed solution eliminated the energy consumption caused by the overhead. The results showed a reduction of energy consumption of 97% compared to LoRaWAN. Bor et al. [START_REF] Bor | LoRa Transmission Parameter Selection[END_REF] presented an analysis of the parameters of LoRa transmissions. The authors focused on the effects of parameter selection in energy consumption and communication performance. The authors stated that an Spreading Factor (SF) of 8, a bandwidth of 500 MHz, 4/5 coding rate and 8dBm of transmission power (tx power) consumed 2.31 mJ and the optimal settings were a SF of 7, a bandwidth of 500 MHz, a coding rate of 4/5 and a tx power of 11 dBm which had an energy consumption of 1.60 mJ. Furthermore, the authors proposed an algorithm that was able to probe different settings and selected the best option in order to balance the energy consumption. Several experiments on the Carrier Sense Multiple Access (CSMA) channel access mechanisms of LoRa were performed by Phan [START_REF] Pham | Investigating and Experimenting CSMA Channel Access Mechanisms for LoRa IoT Networks[END_REF]. The author presented an adaptation of the 802.11 CSMA protocol for LoRa and a new CSMA protocol. The energy consumption of the adaptation and the new proposal with different settings was compared as well. The results showed the new proposal had a lower energy consumption for all settings compared to the adaptation from 802.11. Moreover, Pötsch et al. [START_REF] Pötsch | Practical Limitations for Deployment of LoRa Gateways[END_REF] discussed the limitations of LoRa gateway deployment. The overhead caused by the LoRa gateways is analyzed as well. The energy consumption was compared for different spreading factors and bandwidths of 125MHz, 250 MHz and 500 MHz. The results showed less energy consumption as the spreading factor decreased and the bandwidth increased. Furthermore, the energy consumption increased as the tx power increased, being 50 mA approximately for a tx power of 5 dBm and slightly above 120 dBm for a tx power of 19 dBm.

The energy consumption of WiFi nodes has been studied as well. Mesquita et al. [START_REF] Mesquita | Assessing the ESP8266 WiFi module for the Internet of Things[END_REF] performed a study on the performance of ESP8266 WiFi modules which are branded as ultra-low power. The authors performed several experiments to measure the energy consumption with sleep modes and different transmission configurations. The authors stated that the usual configuration of a Delivery Traffic Indication Message (DTIM) period of 3 and a 100 ms beacon interval had the lowest average current consumption, namely 14.71 mA. They also stated that ESP8266 modules were able to operate for 2 to 4 days with a small battery of 1000mAh of capacity. Montori et al. [START_REF] Montori | Is WiFi suitable for energy efficient IoT deployments? A performance study[END_REF] presented a performance study on WiFi for IoT systems. The authors utilized ESP-12 SoC modules to study their energy consumption under variations of the connectivity settings. Tests were performed with Lo-Po, alkaline and NiMH batteries. The results showed similar performances for all batteries with the same configurations. Furthermore, the difference in energy consumption between awake and sleep mode was less than that stated on datasheets. Lastly, Putra et al. [START_REF] Putra | Comparison of Energy Consumption in WiFi and Bluetooth Communication in a Smart Building[END_REF] performed an energy consumption comparison between BLE and WiFi with different settings for the beacons. Tests were performed for an iPhone device. The results showed BLE had a 30% more energy efficiency than WiFi. Furthermore, the battery life of the smartphone was of 14 hours and 46 minutes for WiFi and 16 hours and 38 minutes for BLE.

To the best of our knowledge, no comparison between the energy consumption of WiFi and LoRa in IoT devices has been performed before. Therefore, in this paper, we compare the effects of WiFi and LoRa transmissions on battery life.

III. WIFI AND LORA TECHNOLOGIES

The two wireless technologies on which we have done our work are IEEE 802.11 (also known as WiFi) and LoRa. Next, we will describe the main characteristics of both technologies.

A. IEEE 802.11 technology

In this subsection, a background on the IEEE 802.11 standards is going to be provided.

The 802.11 standards use the 2.4 GHz and 5 GHz bands. These bands are known as Industrial, Scientific and Medical (ISM) radio bands. They are defined in Article 5 of the Radio Regulations of the International Telecommunication Union (ITU) [18]. These bands do not need a license for their operation, but they differ according to the regulations of each country. The problem that can arise when using them is that other devices can create interference if they work in the same bands.

The modulation techniques most used by the standard are: Binary Phase Shift Keying (BPSK), Quadrature Phase Shift Keying (QPSK), Quadrature Amplitude Modulation (QAM), Direct Sequence Spread Spectrum (DSSS), Complementary code keying (CKK) and Orthogonal Frequency Division Multiplexing (OFDM).

There are three types of frames that are used by the standard: data frames, control frames and management frames.

Data frames transport data between connected stations. The control frames next to the data frames are used to carry out area cleaning operations, channel acquisition and maintenance functions associated with the carrier and acknowledgments (ACK). The management frames are used to join or leave the wireless network and move associations of access points. All data frames that are transmitted must have an Acknowledgment of Receipt (ACK), otherwise the transmission will be considered failed.

Figure 1 shows a generic 802.11 data frame. An important difference that can be appreciated, if we compare it with an Ethernet frame, is the larger size of the data field. While a standard Ethernet II frame has a size of 1500 bytes, the data field of an 802.11 frame reaches up to 2312 bytes. The ACK frames have a much shorter length, only 14 bytes. Other frames that should be highlighted in the standard are the Request to Send (RTS) and Clear to Send (CTS) frames. RTS and CTS frames are used to avoid collisions. The size of the CTS frame is 14 bytes while the RTS frame has a length of 20 bytes.

Within the IEEE 802.11 standard, our nodes have implemented the IEEE 802.11n, but working in the 2.4 GHz band. As defined in the standard, if 20 MHz channels are used, the theoretical maximum data transmission speed is of 72.2 Mbps, and if 40 MHz channels are used, the maximum theoretical data transmission speed is of 150 Mbps, when a single stream of spatial data is transmitted.

With regard to power management, the 802.11 standard has a defined system. It is a mechanism that allows energy savings and is called Power Saving. The stations that work in that mode are known as PS-STAs (Power Save Stations). In order for them to work properly, their control must be carried out by an Access Point (AP). The AP must have all the PS-STAs registered. If a station is not active, the AP will store the packets that are directed to the station until it requires them. Periodically, the stations must be activated in order to listen if the AP has data for them.

B. LoRa technology

In this subsection, a background on LoRa and the structure of LoRa packets is going to be provided.

LoRa stands for Long Range and is a patented spread spectrum technology developed by Semtech Corporation.

LoRa operates in the lower ISM bands (EU: 868MHz and 433 MHz, USA: 915MHz and 433 MHz). The transmission data rate can be from 0.3 kbps to 27 Kbps with a bandwidth of 125 KHz. It is widely used for Machine To Machine (M2M) applications from IoT.

LoRa uses a modulation technique derived from Chirp Spread Spectrum (CSS). It applies an adaptive modulation technique with a multichannel multimode transceiver in the base station to receive a multiple number of messages from the channels. The relationship between the required data bit rate with the chirp rate and the symbol rate in the LoRa modulation technique [START_REF] Semtech | LoRa Modulation Basics[END_REF] is defined as follows:

Rb = SF • 1 / (2 SF /BW) bits/s (1)
where Rb is the modulation bit rate for LoRa, SF is the scattering factor and BW is the modulation bandwidth in Hz. As seen in ( 1), the data rate Rb is directly proportional to the scattering factor SF.

Figure 2 shows the structure of a LoRa packet. SF is the ratio between the symbol rate and chip rate. The higher the dispersion factor, the higher the Signal to Noise Ratio (SNR). The number of chips per symbol is calculated as 2 SF . For example, if the scattering factor SF is 12, 4096 chips / symbol are used. Each time SF is increased, the transmission speed is halved. This causes the duration of the transmission to be doubled, which leads to an increase in energy consumption.

The nodes are transmitted directly to a gateway that connects to the backbone network. Gateways are capable of receiving and decoding multiple simultaneous transmissions (up to 50).

Three node classes [START_REF] Sinha | A survey on LPWA technology: LoRa and NB-IoT[END_REF] have been defined: 1) Class A devices:

The node transmits to the gateway when necessary. After transmission, the node opens a reception window to obtain messages from the gateway.

2

) Class B final devices with programmed reception spaces:

The node behaves like a Class A node but opens additional reception windows at scheduled times. Beacons from the gateway are used for the timing of the end devices.

3) Class C terminal devices with maximum reception spaces:

These nodes are continuous listening, which makes them unsuitable for battery operations.

To configure a LoRa interface, we must take into account the following four parameters: carrier frequency, spreading factor, bandwidth and coding rate. Depending on the parameters that are selected, the energy consumption, transmission range and resilience to noise will be determined.

IV. TESTBED

In this section, the node and the explanation of the test are going to be presented.

In order to perform the tests on energy consumption, we utilized the Heltec WiFi LoRa 32 node which is presented in Figure 3. It is able to transmit with both WiFi and LoRa. This node has an ESP32 microprocessor and a LoRa SX1278 node chip. It has an SH1.25-2 battery interface onboard as well and an integrated management system for lithium batteries so as to manage charge and discharge, switch automatically between USB and battery power, protect against overcharge and detect battery power. It also has an integrated OLED (Organic Light-Emitting Diode) display, a CP2102 USB to serial port chip and supports the Arduino IDE (Integrated Development Environment). It is comprised of 29 general GPIO (General Purpose Input7Output) ports. It has 3 UART (Universal Asynchronous Receiver-Transmitter) ports, 2, SPI (Serial Peripheral Interface) ports, 2 I2C (Inter-Integrated Circuit) ports and one I2S (Inter-IC Sound) port. It also has a 4 MB flash memory. Table 1 shows the energy consumption provided by the manufacturer [START_REF]Specifications of the Heltec WiFi LoRa 32[END_REF].

In order to perform the tests, the Heltec WiFi LoRa 32 v2 was programmed using the Arduino IDE. The WiFi.h and LoRa.h libraries were utilized to establish the connection between the two Heltec WiFi LoRa 32 v2 nodes. The default settings were utilized for both WiFi and LoRa. Table 1 shows the default settings for LoRa. The forwarded data was the same for both WiFi and LoRa transmissions and it had a length of 80 bytes.

Tests were performed forwarding a packet with a 5 second interval and a 30 second interval. The utilized battery was a 4955 power bank with a capacity of 2000 mAh and an output of 5V DC and 1000 mAh.

V. RESULTS

In this section, the obtained results are going to be presented.

The tests on the energy consumption of WiFi were performed for the two selected transmission time intervals. Figure 4 shows the average battery life for each transmission interval. As it can be seen, a difference of 1 hour was obtained between transmitting with each time interval. For the time interval of 5 seconds, the obtained battery life was 10 hours and 10 minutes whereas 11 hours and 14 minutes of battery life was obtained for the 30 seconds time interval. Therefore, the transmission interval can severely affect the energy consumption of the devices that utilize WiFi for their communication.

The tests performed with LoRa considered 5 seconds and 30 seconds time intervals as well. However, no significant differences were obtained between both transmission intervals. In fact, the average battery life for the 30 seconds transmission interval was 26 minutes less than that of the 5 seconds transmission interval. As it can be seen in Figure 5, the lifetime of the battery was approximately 10 hours.

As the manufacturer stated, the power consumption for both WiFi and LoRa transmissions is practically the same with transmission powers of 17 dBm or 18 dBm. It is surprising as LoRa is branded as a low-power consumption communication protocol. Therefore, the transmission power of LoRa has to be decreased so as to improve its battery consumption, which leads to less coverage. To assess if the battery life was increased when transmitting with less transmission power, another test was performed changing the tx power of the LoRa transmissions to 10 dBm. The time interval for this test was 30 seconds. The average battery life for this case is presented in Figure 6. As it can be seen, the battery life improved compared to that with a transmission power of 17 dB, obtaining more than one hour more of battery life. Furthermore, the battery life surpassed that of WiFi with a transmission interval of 30 seconds in 20 minutes. The difference would be then more noticeable when utilizing batteries with more capacity. However, the overall difference between the power consumed by both technologies is not that great. Therefore, other factors, such as the range that can be reached with each technology or the data rate may be the factors to be considered when selecting the wireless technology to be utilized in an IoT system.

VI. CONCLUSION AND FUTURE WORK

When designing an IoT system, the selection of the communication technology is of great importance. LoRa is supposed to have less power consumption than WiFi but the difference is not that evident and LoRa settings have to be changed to lower transmission power values, lower SF and increase bandwidth for it to consume less power. In the case of the Heltec WiFi LoRa 32 device, similar results have been obtained for both LoRa and WiFi with the default settings and 5 seconds of transmission interval. However, WiFi outperformed LoRa with a 30 second transmission interval. A similar battery life was obtained when lowering LoRa transmission power to 10 dBm.

As future work, we will implement WiFi and LoRa in an agriculture and irrigation monitoring system selecting the technology depending on the range that needs to be reached.

Figure 1 .

 1 Figure 1. 802.11 generic data frame

Figure 2 .

 2 Figure 2. Structure of a LoRa packet.

Figure 3 .

 3 Figure 3. Utilized Heltec WiFi LoRa 32 node

Figure 4 .

 4 Figure 4. Battery life with WiFi communication

Figure 5 .Figure 6 .

 56 Figure 5. Battery life with LoRa communication

TABLE I .

 I ENERGY CONSUMPTION OF THE NODE

	Mode		Energy consumption
	LoRa 10 dB tx power	50 mA
	LoRa 12 dB tx power	60 mA
	LoRa 15 dB tx power	110 mA
	LoRa 20 dB tx power	130 mA
	WiFi AP mode		135 mA
	WiFi scan mode		115 mA
	TABLE II.	ENERGY CONSUMPTION OF THE NODE
	Tx Power		17 dB
	Frequency		433 MHz
	SF		7
	Signal Bandwidth	125 KHz
	Coding rate		4/5
	Preamble length	8 Symbols

Copyright (c) IARIA, 2019. ISBN: 978-1-61208-730-6 SMART 2019 : The Eighth International Conference on Smart Cities, Systems, Devices and Technologies

ACKNOWLEDGMENT

This work has been supported by European Union through the ERANETMED (Euromediterranean Cooperation through ERANET joint activities and beyond) project ERANETMED3-227 SMARTWATIR.