Cannnot send from arduino to raspberry pi via LoRa

Internet of Things Asked by metichi on August 6, 2020

I am trying to send messages from my arduino to my raspberry pi. But I don’t understand why the pi isn’t receiving the messages.

On the arduino side Im using an arduino UNO with a Dragino Lora/GPS shield, using the Radiohead library.

On the Pi side, the Upotronics LoRa hat for the pi zero and a pi zero, which is based on a RFM95 chip. And on the software side I’m using the Raspi Lora library.

I wrote a couple of simple programs just to test the connection, and I can send messages from the raspberry to the arduino, but not the other way around.

Am I making a mistake in the code on either sending the data from the arduino or receiving it on the raspberry that prevents this?

Code for the arduino: This one sends data it gets from serial port and awaits radio input when nothing is available.

#include <SPI.h>
#include <RH_RF95.h>

RH_RF95 rf95;

void setup(){
  if (rf95.init()){
    Serial.println("Init Success");
  } else {
    Serial.println("Init Failed");
  if (rf95.setFrequency(868)) Serial.println("Freq set for 868Mhz");
  if (!rf95.setModemConfig(RH_RF95::Bw125Cr45Sf128)) Serial.println("Invalid modem");

  Serial.println("Send serial data to echo it through radio");

void loop(){
  uint8_t data[100];
  uint8_t len;
  if (Serial.available()){
    int i = 0;
    while (Serial.available() && i < sizeof(data)-1){
      data[i] =;
      data[i] = 0;
      Serial.print("Message sent: ");
      Serial.println((char *) data);
    } else {
      Serial.println("Failure to send");

  if (rf95.available())
    if (rf95.recv((uint8_t *)data,&len)){
      Serial.println("Got it");
      Serial.println((char *)data);

Raspberry pi code: This one just initializes the lora instance, I run it on the interactive console and in theory it should print data, but as much as I tried I haven’t managed to catch an IRQ on any of the pins when I send a message.

from raspi_lora import LoRa, ModemConfig

# This is our callback function that runs when a message is received
def on_recv(payload):
    print("From:", payload.header_from)
    print("Received:", payload.message)
    print("RSSI: {}; SNR: {}".format(payload.rssi, payload.snr))

lora = LoRa(0, 25, 2,freq=868, receive_all=True, modem_config=ModemConfig.Bw125Cr45Sf128)
lora.on_recv = on_recv


One Answer

I figured it out. Turns out there was a bug in the raspi_lora library I used for my python code. It is so that, if you are not specifically sending to the device address or have receive_all=True , it will do nothing with the messages.

If you plan to use the raspi_lora library you should replace line 268 in the file with

if (self._this_address != header_to) and ((header_to != BROADCAST_ADDRESS) or (self._receive_all is False)):

Correct answer by metichi on August 6, 2020

Add your own answers!

Related Questions

ESP OTA from Github

1  Asked on November 7, 2021 by sembei-norimaki


Do you know of any product that uses the uCOS RTOS?

1  Asked on November 7, 2021 by kelvin-armitage


Signal Processing in LoRa

2  Asked on August 23, 2021 by pankajkumar


Mini weather station project not working

0  Asked on August 23, 2021 by dharshinii-ravikumar


802.11 action frames send and receive in software

3  Asked on August 23, 2021 by alexandr-zarubkin


What is wrong with this MQTT-SN bridge?

1  Asked on August 23, 2021 by omarl


GSM enabled Linux device with USB link

2  Asked on August 23, 2021 by mark-whitfeld


can a shelly switch control a different shelly relay?

1  Asked on August 23, 2021 by longneck


wireless moisture data transmission

2  Asked on August 23, 2021 by fahad-najib


Testing security of IoT devices

2  Asked on August 23, 2021 by typo


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP