What is LoRaWAN Internet of Things protocol and how does it work?
If you have been fiddling with some Internet of Things development boards and Wireless Sensor Networks, you should already have heard of LoRaWAN communication protocol and other Wireless communication protocols. During my master degree, I worked many times with LoRaWAN protocol, both for my final thesis and some homemade projects, like the LoRaWAN Single Channel Gateway which I illustrated in THIS tutorial.
But what is LoRaWAN? How can a 10 dollar board achieve an operating range of many kilometres? What’s the difference between LoRaWAN and LoRa? Are they the same thing?
I will try to answer to all these questions in this article, where I will explain what I learned during my master degree in Communication Engineering working on this wonderful but limited Long Range communication protocol widely used in many Internet of Things applications.
Table of Contents
LoRaWAN: the cheapest Internet of Things Long Range communication protocol
What’s the difference between LoRa and LoRaWAN?
LoRaWAN is a Long Range communication protocol often used to create Low Power Wide Area Networks (LPWANs) with an operating range that goes from 300 meters up to 10 kilometres. Among the main LPWANs protocol, LoRaWAN is one of the most know and used, given its open architecture. Talking about LoRa and LoRaWAN, it must be specified that the two terms refer to different things: LoRaWAN is a protocol which PHY layer is based on LoRa modulation while the Medium Access Control (MAC) layer is an open network architecture regulated by the LoRa Alliance. LoRa instead, is a proprietary modulation based on Chirp Spread Spectrum (CSS) which refers to the Physical layer. LoRa protocol is also patented by Semtech Corporation, which is the only LoRa transceiver chips producer. Therefore, in the OSI protocol stack, LoRaWAN (Network Layer) rely on LoRa (Physical Layer), as visible below, since it defines the network media access rules, the authentication method, device profile and data encryption.
Another difference between LoRa and LoRaWAN is the network topology, since LoRa allows only Point-To-Point links, while LoRaWAN, given its nature of Network Layers, defines all the needed rules to create a multiple stars network topology composed by many LoRaWAN end nodes and gateways. Gateways acts as bridge between the LoRaWAN network and IP-based networks, delivering data from end nodes to one or more applications servers and vice-versa.
How LoRa modulation work?
LoRa modems modulate symbols into increasing and decreasing frequencies chirps, respectively called up-chirps and down-chirps, as visible in the following illustration.
Each LoRa transmission has a Preamble and a Start-Frame-Delimiter (SFD), which precede the encoded core data in order to initiate and lock the LoRa receiver, in order to correctly listen the incoming transmission. In turn, SFD and Preamble have different polarity, so they use up-chirps and down-chirps, respectively, depending on these polarity settings.
LoRa modulation has many parameters, which can partially be modified, depending also on the operating region of the system. They are:
- Carrier Frequency: it defines the carrier frequency of the medium used for both transmission and listening operations. It also depend on the operating region: in Europe, the LoRa operating carrier frequency is the EU 863-870MHz ISM band, while in US it is the 902-928~MHz ISM band;
- Signal Bandwidth: it represent the width of the LoRa RF signals. It is typically set to 125kHz, but can be increased up to 250kHz or even 500kHz in some regions for particular modulations parameters;
- Coding Rate: it is a parameter which defines the Forward Error Correction (FEC) rate used by LoRa transmitters and receivers in order to reduce the destructive effects of the RF interference. It affects the symbol airtime, since it increases the symbol overhead to make it more noise-resistant. By default its value is set to 4/5;
- Spreading Factor: it represent the chirp spreading parameter, defining how many chirps are sent per second. I ranges among SF7 and SF12. In detail, a large SF increases the symbol airtime and the energy consumption, thus improving the communication range, but reducing the available data rate and messages’ payload size;
- Transmission Power; it is the energy irradiated by the LoRa node’s antenna. Moreover, it can range from -4 dBm up to +20 dBm (+14 dBm in Europe), but different regions could have different power limits;
- Chirp Polarity: it defines the polarity of the transmitted chirps. It is often defined by the different protocols implementations, since, as example, LoRaWAN gateways transmit packets to end-nodes using an inverted polarity modulation, so that these messages are discarded by neighbour gateways, while end-devices transmit packets using non-inverted polarity, in order to be received only by the gateways;
- Sync Word: it is a one-byte value parameter defined by the last two up-chirps of the Preamble and used to differentiate LoRa networks using the same frequency bands. Any device configured with a given Sync Word will discard any incoming transmission if the Sync Word is diffrent from the defined one. Typically, the Sync Word parameter for private LoRa networks are 0x12 for Semtech SX127x devices and 0x1424 for SX126x devices, while public LoRa networks (such as LoRaWAN or TTN) are represented by values equal to 0x34 for Semtech SX127x devices and 0x3444 for SX126x devices.
How many LoRaWAN device classes exist?
LoRaWAN end nodes can also be classified into three categories: Class A, B, and C. All LoRaWAN devices must implement Class A, whereas Class B and C are extensions of Class A devices. These classes, defines the behaviour about downlink packets from gateways to end nodes. A Class A device support bi-directional communication but, while uplink messages can be sent at any time, downlink messages can be received only during two specific windows at specified times after an uplink transmission, allowing the lowest energy consumption mode. Class B devices are suitable for downlink related activities, since a time-synchronised receiving window is periodically opened through beacons. Class C devices instead, keep the receiving window open unless they are transmitting again, strongly increasing the power consumption. Usually LoRaWAN gateways acts as Class C devices, since they are constantly listening for incoming transmission.
In order to transmit and receive data over LoRaWAN network, LoRaWAN end nodes must be registered and enabled on the Application Server provider, which manages the open network gateways. Therefore, LoRaWAN device can join the network in two ways: through an Over-The-Air-Activation (OTAA), or with an Activation-By-Personalization (ABP) method. Both methods works well, but the first one is more secure, since each times that the end node sends a join-request, it receives a join-accept with a NetID, DevAddr and an AppNonce which are used by the device to generate a NwkSKey and AppSKey in a secure way. An ABP device instead, has already both DevAddr, AppSkey and NwkSkey, which are sent over the network at each transmission in order to identify itself.
Which are LoRaWAN payload, ranges and bitrates?
LoRa modulation is characterised by a Spreading Factor (SF) which defines the airtime duration of the chirp. Increasing the SF increases the symbol time, allowing the signal to travel over a longer distance. Limiting the study to the free 868 MHz European band used by LoRa, SF can vary between 7 and 12, where SF equal to 7 allows the greater data rate and lower symbols airtime, while SF equal to 12 returns the highest sensitivity and transmission range with the lowest data rate and higher energy consumption, given by the longer transmission duration. SF and the relatives bit rates, are reported in the following illustration, which also show other modulation informations, like the signal bandwidth (typically 125 kHz in Europe), the minimum receiver sensitivity and the relative operating range, power consumption and airtime.
One of the most important thing to know when working with LoRaWAN is the maximum packet payload for each SF. Given LoRa low power and low data rate nature, optimal for many Internet of Things applications, the packet payload is very susceptible to the used SF, since this parameter acts on the transmission data rate. LoRaWAN network layer typically uses 13 bytes as packet header for the operation of the protocol, a not negligible value that at high SF significantly affects the maximum payload of the package. Maximum payload size is reached with SF7, which allows up to 222 bytes of user’s data inside a single Lora packet. The minimum, instead, is reached with SF set to 12, with a limit of 51 bytes for user’s data. Payload limits, data rates, bitrates, receiver sensitivity and typical operating range related to each SF with a bandwidth of 125 kHz at a carrier frequency of 868 MHz, are shown in the following table.
Despite this, the real world LoRaWAN operating ranges could be very different. In my Line-of-Sight LoRaWAN range test, for example, I could achieve an operating range of several tens of kilometres without any obstacles in the middle, with a peak at about 75 kilometres. You can check more detail about my LoRaWAN Line-of-Sight tests HERE. However, in a semi-urban environment, the operating ranges are different, as visible in THIS article.
Which are LoRaWAN European channels and frequencies?
LoRaWAN protocol uses eight uplink (from end nodes to gateways) channels defined inside the EU863-870 MHz free ISM band. Uplink channels can also be used as downlink channels on the first receiving window, but there is also a ninth channel defined at the frequency of 869.525 MHz used only for the second receiving window. Both uplink and downlink channels of the EU863-870 MHz free ISM band are shown in the following picture.
There is also a ninth uplink channel, which has a fixed frequency of 868.8 MHz frequency, but uses an FSK modulation. Another key feature of LoRaWAN protocol is the Radio Medium Access, based on ALOHA protocol, which was developed at the University of Hawaii back in 1970s.
Which are LoRaWAN fair usage policies?
LoRaWAN network has some strictly policy rules, which must be respected for a fair network usage. These are:
- any device has a daily maximum cumulative airtime of 30 s for uplink messages;
- any device has a maximum of 10 daily downlink messages, which includes ACKs.
Since airtime depends on SF and messages payload, the daily messages limit strictly depends on these two parameters. For example, for a fixed 10 bytes payload, this translates to up to 20 daily uplink messages with SF set to 12 or around 500 daily uplink messages with SF7. Also, LoRaWAN devices must respect bandwidth duty cycle, which depends from region to region. For EU868 MHz free band, duty cycle goes from 0.1 % to 10 %, depending on the channel used. This means that every time a device transmit over a LoRaWAN channel, it can not transmit on this channel for a certain amount of time, which is usually computed by the device itself starting from the previous transmission airtime.
Finally, another parameter that LoRaWAN devices must respect is the maximum transmit power, which, for the EU868 MHz band, is set to +14 dBm, as defined by the European Telecommunications Standards Institute (ETSI) European laws.