How to use LoRa with Raspberry PLC

Basic tutorial on the usage of the LoRa module with Raspberry PLC Family
May 23, 2024 by
How to use LoRa with Raspberry PLC
Boot & Work Corp. S.L., Martí Schnabel

Can LoRa be used for Raspberry Pi?

Absolutely, LoRa can be used with Raspberry Pi through the PLC powered by Raspberry Pi, which features two communication boards specifically designed to support LoRa modules for different regions, including Europe, Asia, and the USA. This integration allows you to harness the power of LoRa technology for a wide range of IoT applications. The Raspberry PLC supports:


  • RN2483 module which operates at a frequency of 433MHz or 868MHz.
  • RN2903 module which operates at a frequency of 915MHz.

The following table shows the regions supported for each module according to its operational frequencies values. For more information about the frequency plans by country of LoRaWAN check this page.

Module

Frequency (MHz)

Region

RN2483

433

Europe

RN2483

868

Asia

RN2903

915

North America

Essential Hardware for using LoRa ​with Raspberry Pi

To successfully set up LoRa communication with Raspberry Pi via the Raspberry PLC, it's important to gather all the necessary hardware components. This section outlines the required equipment to ensure smooth and effective operation of your LoRa modules.


The hardware requirements are:

  • One Raspberry PLC in case of already having another device to communicate with. Otherwise, you can have two Raspberry PLCs to communicate between each other.
  • The LoRa module according to your region connected to one of the communication boards of the Raspberry PLC.
  • An antenna connected to the LoRa module. Note that in case of the LR module, it has two antenna connectors: RFL for 433MHz and RFH for 868MHz.

How to test LoRa communication with PLC powered by Raspberry Pi

To ensure that your LoRa modules are communicating effectively with your Raspberry Pi and Raspberry PLC setup, follow these detailed testing steps. This guide will help you verify the connection and functionality of your LoRa devices, ensuring they are properly configured for your IoT applications.


To test the LoRa communication between two devices follow this steps:

1. Make sure your Raspberry PLC has our library librpiplc. You can find it in our repository and install it following the installation guide.

2. Ensure that the /boot/config.txt file ends with these lines:

[all]
dtparam=spi=on
gpio=8=pd
dtoverlay=spi0-1cs,cs0_pin=7
dtoverlay=w5500,cs=0,int_pin=6
dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds3231
dtoverlay=sc16is752-spi1-rpiplc-v4,xtal=14745600
enable_uart=1

Otherwise, replace the previous configuration for this one and reset the PLC.

Note that for the following instructions the PORT parameter is either /dev/ttySC0 for the expansor 1 and /dev/ttySC1 for the expansor 2. The expansor 1 is the one closer to the Ethernet port.

3. Set the reset pin to high to enable the LoRa module:

  • For the expansor 1, execute sudo ~/test/[RPIPLC_Version]/[RPIPLC_Model]/set-digital-output EXP1_RST 1
  • For the expansor 2, execute sudo ~/test/[RPIPLC_Version]/[RPIPLC_Model]/set-digital-output EXP2_RST 1

4. To open the port at 57600 baudrate (it is the module's default baudrate), execute: stty 57600 -F [PORT] raw -echo

5. To leave the port listening, execute: cat [PORT]

6. To check if the RPi communicates with the module, execute: echo -e "sys get ver\r" > [PORT] while listening to the port in another terminal.

7. To send a command, execute: echo -e "[COMMAND]\r" > [PORT]

For instance, here are some useful commands:

  • mac pause to pause the LoRaWAN stack functionality to allow transceiver (radio) configuration​.
  • radio rx 0 to listen for data.
  • radio tx ABC to send a message (ABC).
  • radio set freq [FREQUENCY] to set the communication frequency of the radio transceiver.

For more information about all the possible commands on the RN2483 and RN2903 modules check:


Enhancing IoT with LoRa and Raspberry Pi

Integrating LoRa modules with Raspberry Pi through the Raspberry PLC family significantly enhances the capabilities of your IoT projects. By following the comprehensive guide on hardware setup, software configuration, and communication testing, you can ensure seamless and reliable LoRa communication across various regions. The use of RN2483 and RN2903 modules allows for flexible frequency options, catering to Europe, Asia, and North America. With proper setup, you can achieve efficient long-range communication, making your IoT solutions more robust and effective. For detailed commands and further customization, refer to the RN2483 and RN2903 module references.


​Search in our Blog

How to use LoRa with Raspberry PLC
Boot & Work Corp. S.L., Martí Schnabel May 23, 2024
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>