Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Best practices for securing LoRa networks

By Ayush Jain August 13, 2024

This article explains how to establish secure communication between two LoRa end-node devices using Lora E5 mini boards. LoRa, which stands for “long range,” is a wireless technology with the ability to send small amounts of data over large distances.

Two end-node devices can exchange encrypted messages. The transmitting device encrypts the message before sending it and waits for a confirmation response. Upon receiving the encrypted message, the receiving device sends a confirmation and displays the decrypted message on the serial monitor.

The following guide offers insights into implementing encryption for seamless and secure communication between LoRa end-node devices.

Figure 1. The block diagram of two LoRa end-to-end devices.

Abstract

  1. A list of the most common and secure encryption algorithms
  2. How to upload firmware to the LoRa E5 mini board
  3. How to send and receive messages
  4. The program flow or algorithm and explanation

Requirements

  1. LoRa E5 mini board by Seed Studio.

Common encryption algorithms

The following encryption algorithms are widely recognized for their security and widespread use:

  1. AES (Advanced Encryption Standard): a top-tier symmetric encryption algorithm trusted globally by governments, organizations, and individuals for its reliable security. It has become the standard for several applications.
  2. RSA (Rivest–Shamir–Adleman): a well-known asymmetric encryption algorithm essential for secure key exchange, digital signatures, and other cryptographic tasks. It’s based on factoring large composite numbers.
  3. ECC (Elliptic Curve Cryptography): a popular asymmetric encryption method, valued for its strong security with shorter key lengths — offering equivalent security to algorithms like RSA but with greater efficiency.
  4. SHA-256 (Secure Hash Algorithm 256): a member of the SHA-2 family that’s commonly used for data integrity checks and digital signatures. It’s highly secure and widely implemented across various applications.
  5. ChaCha20: a modern symmetric encryption algorithm celebrated for its high performance and security. It’s a popular alternative to AES in applications like HTTPS and VPNs.
  6. HMAC (Hash-based Message Authentication Code): not an encryption algorithm, but commonly employed to create secure message authentication codes (MACs) using cryptographic hash functions. It’s essential for ensuring data integrity and authentication.
  7. Diffie-Hellman Key Exchange: enables the secure exchange of cryptographic keys over a public channel. It’s also fundamental to secure the keys in many protocols.

Uploading code to the LoRa E5 mini

The firmware leverages the AES (Advanced Encryption Standard) encryption algorithm to ensure security. Both devices use the same code.

Messages are entered as plain text through the serial monitor, where the transmitting device automatically encrypts them before they’re sent. The receiving device then decrypts the message and displays the decoded content in a readable format on the serial monitor. This streamlined process guarantees secure communication while maintaining user-friendly readability.

1. To ensure the LoRa code flashes correctly, select the genuine ST-Link V2 with an STM chip. Be cautious of imitations with Chinese chips, as they may not perform as well. Using the original ST-Link is recommended for the best results.

Figure 2. The original ST-Link V2.

2. Connect five wires — 3V3, SWDIO, SWCLK, RST, and GND — to the LoRa E5 mini board as shown below.

Figure 3. The ST-Link connection with the LoRa E5 mini board.

3. Open the STM32CUBE Programmer and click on the “Connect” button.

Figure 4. The STM32CUBE programmer connect target.

4. Select the hex file by clicking on the “Open File” tab.

Figure 5. Open the hex file.

5. Click on “Download” to upload the code.

Figure 6. Upload the code.

6. A pop-up should appear on the screen, indicating that the download is complete.

Figure 7. Download complete.

How to send and receive messages

Figure 8. Sending and receiving messages.

Connecting devices and using the serial terminal

Connect both devices to your computer and open the serial terminal. We use Arduino’s serial terminal.

1. Select the appropriate port for each device and set the baud rate to 9600. Then, choose the “NL & CR” option.

Figure 9. The serial terminal.

2. Try sending a message via one of the serial terminals. On the TX terminal, both the encrypted and plain text messages will be displayed. Encrypted messages are prefixed with “Encrypt MSG:” while the plain text messages are labeled, “TX MSG:“. Upon successful reception by the RX device, the message “SENT CONFIRMD” will appear, confirming delivery. This setup provides a clear view of the transmitted content and confirmation status, improving the communication monitoring process.

Figure 10. The TX terminal.

3. On the RX terminal, encrypted messages are clearly marked with the “Encrypt MSG:” prefix, while decrypted messages are shown with the “RX MSG:” prefix. This makes differentiating between encrypted and decrypted messages easy, ensuring better comprehension of the received data.

Figure 11. The RX terminal.

The algorithm

Figure 12. The algorithm for securing the LoRa networks.

The code explanation

The LoRa Firmware is different from other STM codes. For example, the “c” is not the main code. Rather, the main file is “subghz_phy_app.c” as shown in the image below.

Figure 13. The main code file.

1. This function starts the UART interrupt, which is alerted to wake up and read any messages.

Figure 14. The UART interrupt.

2. The UART RX calls back the function (provided below). In this function, the UART RX data is stored in “circBuffer” until it detects ‘\n’. Then, it encrypts the string, sending it to the LoRa board.

Figure 15. The UART RX function.

3. When a message is received on LoRa, it first prints an RSSI.

Figure 16. Printing the RSSI.

4. After printing the RSSI, the RX buffer is detected from LoRa. If the RX data is ‘*’, then “Sent Confirmed” is printed, confirming that data has been received from the other device. If the RX data is something else, it decrypts the data first and then prints it on the UART.

Figure 17. The printed message.

A secure messaging device

This messaging device example is practical in situations where data security is critical. Adding a screen, keypad, and battery enhances its portability, while a power-saving sleep mode can extend battery life for years. Adding a battery (and sleep mode) would make the device particularly beneficial in remote areas without Internet access.

Overall, this LoRa setup would ensure secure communication and reliable operation in nearly any situation.

 

You may also like:


  • How to build a LoRa gateway using Raspberry Pi

  • How to set-up and use the Heltec LoRa 32 board

  • How to combine a gateway and server when using LoRa

  • What are the programming essentials for LoRa nodes?

  • How LoRa can impact smart cities with parking sensors

  • Understanding LoRa architecture: nodes, gateways, and servers

  • How communication works between two LoRa end-node devices

Filed Under: Tutorials
Tagged With: longrange, lora, loratechnology, networks, tutorial, wireless
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Voltage mode pushpull is a nonsense SMPS?
  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • How to simulate power electronics converter in PSpice?

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe