DEV Community

Cover image for IoT application using LoRaWAN Network Server
Oleksii Borisenko
Oleksii Borisenko

Posted on

IoT application using LoRaWAN Network Server

This story is about how my team and I developed an IoT application for parking that received data from IoT sensors, processed data, and displayed it. Also, in the solution, we have many features connected with booking parking slots, etc.
Of course, since the time this application was created and is running (2019), other competitive solutions have significantly developed. The solution that uses computer vision or cheap sensors for underground parking is more effective, more inexpensive, or easy to deploy in some cases. The experience described below can also help create IoT applications to interact with various other sensors that work using sensors of movement, door opening, light, temperature and humidity, water meter, kilowatt-hour meter, etc.

Сomponents used in this solution:

  • Smart Parking devices (Libelium Smart Parking, TBS-220 geomagnetic vehicle detector)
  • LoRa Gateway (Cisco Wireless Gateway for LoRaWAN)
  • LoRaWAN Network Server (Actility or Open source LoRaWAN server)
  • IoT app can be deployed on IoT compute gateway

IoT scheme

Why LoRa?

  1. Extended range of one radio gateway - up to 15 km radius outside the city area (up to 10 in the city).
  2. Unlicensed frequency band - no use permit is required.
  3. Scalability - up to 20,000 end sensors per 1 gateway.
  4. Low cost of both end devices and radio gateways.
  5. Due to its low power consumption, the sensor runs on an average of 4-5 years of battery life, allowing it to be placed anywhere without wiring and power.
  6. Data Security - All data is encrypted by AES-128 by default; each sensor has its unique encryption keys.

In general, security aspects are also problems in this area. For example, there were a lot of cases when a home IoT system, based on an open source, was hacked, and the attacker was in control of turning on the light and getting control of other devices (blinds, electrical appliances, etc.) And also getting access to IP cameras.

different technologies for IoT
Table comparing different technologies for IoT

Are Sigfox and LoRa still competitors? Unfortunately, yes. But people aren’t as focused on network technology these days — they’re focused on use cases and applications. As a result, these technologies have been relegated to their proper place — they’re tools, nothing more.

Each LoRa device sensor has unique parameters for recognizing in LoRa network and encrypting the data payload:

  • Device EUI
  • Device Address
  • Network session key
  • Application session key

IoT device interface
Many IoT device manufacturers have apps and interfaces for configuring devices and firmware.

Some other settings:

  • LoRaWAN join mode, ABP or OTAA
  • LoRaWAN port
  • LoRaWAN application key
  • LoRaWAN application EUI
  • LoRaWAN EUI that will be loaded from the device.

Network Server interface, device configuration
Image description

Interaction with the sensors

For interaction, we use Uplink and Downlink. Uplink is what we receive from a sensor or IoT device, and Downlink is the data we can send to IoT devices.
We can have 12 bytes payload in the uplink, more precisely 96 bits.


What information can we extract from this?
ID of the device, Battery level, Status of the parking slot, Temperature (Celsius degrees) from the node’s internal sensor.

For example
Payload: 0400003f34b909173f600fc2


Python function that we use for extract the data

    def parsing_payload_hex(data, payload_key="{}payload_hex"):
            _hex = data[payload_key]
        except IndexError:
            raise IndexError('No frame in payloads')
            byte_binary = "{0:08b}".format(int(_hex[:2], 16))

            parking_slot = int(byte_binary[:1])     ## Occupation status    0 - free; 1 - occupied;
            battery = int(byte_binary[1])           ## Charge level         0 - Good; 1 - little;
            frame_type = int(byte_binary[4:8], 10)  ## Frame type           0 - Info; 1 - Keep-alive; 2 - daily update; ...

            return parking_slot, battery, frame_type, int(_hex[2:4], 16)
            ##       parking_slot|battery|frame_type|frame_counter
Enter fullscreen mode Exit fullscreen mode


Technology stack: Vue.js, Python, C

Basic capabilities:
The Application with GUI, where admin can add parkings, configure parking slots, assign parking slots to certain IoT devices. Essential features for users like displaying which parking slot is occupied/free. Review which slots are booked/available on a specific date and time. Send links for external users to book places for themselves.


Extra features:
Automatic cancellation of the booked place if the place was not being occupied within 15 minutes of the scheduled time.
Ability to define a fixed parking space as available for booking during a specific period (for example, in case of vacation or business trip)
Display users booking statistics
Integration with 3d party messaging service

App menu

Also, the admin can see statistics. For example, is the slot occupied during the booking period and the number of cancellations.

We use this solution for corporate parking, where we have slots for guests and need to book it for guest customers or partners. Through API app can also send the card number to the 3d party system.


You can test your app using this sandbox

Top comments (1)

dzhonson64 profile image
Kirill Chugunov • Edited

Hello! Great topic. I've made a Smart Parking with the Libelium Smart Parking too. It's my graduated work.
I've completed to get uplink packets from nodes, but now I'm trying to send downlink messages (like Mac-command).

Have you ever sent the downlink messages? I don't understand what the data I shoud send. What the downlink data is consist of?