El Raspberry PLC supports optional click modules for specialised communications. This article shows how to set up LoRa radio communication between two Raspberry PLCs using the RN2483A module. LoRa (Long Range) is a spread-spectrum modulation technique that enables long-range, low-power wireless communications, making it suitable for industrial IoT applications.
Hardware setup
Each Raspberry PLC has two click module slots. The two slots have different wiring, so it is important to know which serial device each one corresponds to.
Click 1
- Insert the LoRa module into click slot 1 with its RFH antenna connected.
- Dispositivo serie:
/dev/ttySC0
Click 2
- Insert the LoRa module into click slot 2 with its RFH antenna connected.
- Dispositivo serie:
/dev/ttySC1 - Verify that the board resistors match the positions shown in the image before use.
Software setup
Antes de continuar, verifica que /boot/config.txt contenga las siguientes líneas. Si falta alguna, edita el archivo con sudo nano /boot/config.txt, guarda y reinicia.
[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
Next, set the reset pin of the click module high. This requires the librpiplc library:
- Clone and install librpiplc desde GitHub:
git clone https://github.com/Industrial-Shields/librpiplc.git && cd librpiplc && make && sudo make install - Dentro del directorio
/test, compila el helper set-digital-output sustituyendoDEVICEpor tu modelo de PLC (por ejemploRPIPLC_58):g++ -o set-digital-output set-digital-output.cpp -L /usr/local/lib -l rpiplc -I /usr/local/include/rpiplc -D DEVICE
- Set the reset pin high for the relevant click slot:
sudo ./set-digital-output EXP1_RST 1 # for click 1 sudo ./set-digital-output EXP1_RST_2 1 # for click 2
LoRa communication test
Esta prueba usa dos Raspberry PLC con el módulo RN2483A en la ranura click 2 (/dev/ttySC1). Abre dos terminales en cada PLC (cuatro en total).
On the first Raspberry PLC, open and configure the port, then put the module into receive mode:
# Terminal 1 - abre el puerto a la velocidad por defecto y escucha stty 57600 -F /dev/ttySC1 cat /dev/ttySC1 # Terminal 2 - solicita la versión de firmware echo -e "sys get ver\r" > /dev/ttySC1
Si la versión del firmware aparece en el terminal 1 (por ejemplo: RN2483 1.0.5 Oct 31 2018 15:06:52), configura el módulo en modo recepción desde el terminal 2:
echo -e "mac pause\r" > /dev/ttySC1 echo -e "radio rx 0\r" > /dev/ttySC1
On the second Raspberry PLC, open the port and send a test message:
stty 57600 -F /dev/ttySC1 cat /dev/ttySC1 echo -e "sys get ver\r" > /dev/ttySC1 echo -e "mac pause\r" > /dev/ttySC1 echo -e "radio tx abc\r" > /dev/ttySC1
Si la transmisión tiene éxito, el PLC emisor mostrará radio_tx_ok y el PLC receptor mostrará radio_rx 0ABC. Esto confirma que la comunicación LoRa funciona correctamente entre los dos dispositivos.
Nota: el módulo RN2483A requiere que los comandos terminen con \r\n. Con echo -e se añade \r explícitamente porque al pulsar Enter solo se envía \n.

Lora communication between two Raspberry Pi PLCs