Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • 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
  • 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:


  • Understanding LoRa architecture: nodes, gateways, and servers

  • How to build a LoRa gateway using Raspberry Pi

  • How communication works between two LoRa end-node devices

  • 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

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 EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

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.

  • Cloning a HDD
  • PDKs setup for Virtuoso
  • Synchronous rectifier chips nil stocked everywhere?
  • improving in delivering a signal from source to load
  • delete my account

RSS Electro-Tech-Online.com Discussions

  • Help please! BLDC driver circuit using the IR2136s and the STP80NF06 MOSFETS
  • need two ICs
  • MLT-8530 Buzzer on ESP32: Why Is the Sound Output Lower Than Expected?
  • Scope Clock CRT Z-Axis - Grid bias positive?
  • Measuring controller current output with a meter

Featured – Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
  • A filter design example
  • Types of filter responses
  • What are the two types of hardware filters?
  • What are hardware filters and their types?

Recent Articles

  • GigaDevices introduces 32-bit MCUs with integrated DSP and FPU support
  • Grinn introduces 8-core SBC supporting AI-ready embedded development
  • EPC’s 100 kHz BLDC inverter supports high-efficiency motion control
  • Melexis announces 5 W smart driver to supports sensorless FOC operation
  • STMicroelectronics’ motion sensor simplifies industrial IoT system design

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • 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
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • 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
  • Guest Post Guidelines
  • Advertise
  • Subscribe