0

I want to setup LoRa point to point communication between two modules. I have 2 NORVI LR406 modules (based on REYAX RYL896) and a Dragino LoRa USB stick. Initially I wanted to setup the communication between a NORVI LR406 and the Dragino but had no success after trying for quite sometime.

Afterwards I also tried with Heltec WiFi LoRa V3 same case for this. At the end I switched to communication between 2 Norvi modules. All of them don't communicate. I tried all these different devices because I thought may be same devices might work because of same hardware and instruction set.

I have searched a lot, followed tutorials for example in this tutorial. The same REYAX modules with simple commands communicated but in my case it didn't happen. Initially both of my modules were lying side by side to each other and later on I also tried at some distance but still didn't have any success. I am a newbie to LoRa and may be doing something wrong. If someone could point out I will be highly grateful.

# NORVI receiver

import serial import time

def setup_lora_usb(port, baudrate=115200, timeout=1): try: ser = serial.Serial(port, baudrate, timeout=timeout) time.sleep(2) # Wait for 2 seconds to allow device initialization print(f"Connected to {port} at {baudrate} baud.") return ser except serial.SerialException as e: print(f"Error connecting to {port}: {e}") return None

def send_at_command(ser, command, delay=1, read=False): if ser: ser.flushInput() # Clear any data in the input buffer command_with_newline = command + '\r\n' ser.write(command_with_newline.encode("utf-8")) # Send command time.sleep(delay) # Wait for response response = ser.readlines() # Read all lines from the response print("Response:") for line in response: try: print(line.decode('utf-8').strip()) except UnicodeDecodeError as e: print(f"Error decoding line: {e}") def main(): try: port = '/dev/ttyUSB0' ser = setup_lora_usb(port)
if ser: send_at_command(ser, "AT+ADDRESS=102") send_at_command(ser, "AT+NETWORKID=6") send_at_command(ser, "AT+BAND=868500000") send_at_command(ser, "AT+PARAMETER=7,9,1,7") send_at_command(ser, "AT+MODE=0") send_at_command(ser, "AT+CRFOP=15") print("Receiving message...") while True: if ser.in_waiting > 0: response = ser.read(ser.in_waiting) print(response.decode('utf-8').strip()) time.sleep(2) else: print("Failed to connect to the device.") except KeyboardInterrupt: pass

if name == "main": main()

# Dragino LA66
def main():
    port = '/dev/ttyUSB0'
    ser = setup_lora_usb(port)    
    if ser:
        # send_at_command(ser, 'AT?')
        send_at_command(ser, 'AT+BW=0,0')
        send_at_command(ser, "AT+RXMOD=65535,2")
        send_at_command(ser, 'ATZ')
        send_at_command(ser, 'AT+FRE=868.500,868.500')
        send_at_command(ser, "AT+GROUPMOD=10,10")
        send_at_command(ser, 'AT+SF=10,10')
        send_at_command(ser, "AT+CR=1,1")
        send_at_command(ser, "AT+PREAMBLE=7,7")
        send_at_command(ser, 'AT+CFG')
        for i in range(5):
            send_at_command(ser, "AT+RECV=1")
        ser.close()
    else:
        print("Failed to connect to the device.")

if __name__ == "__main__":
    main()
// ESP32 controller where NORVI LR406 is connected
#define RTLX_RX 0
#define RTLX_TX 25

HardwareSerial lora_serial(2);
String sendCommand(String command) 
{
  lora_serial.println(command);
  delay(1000);
  Serial.println("\nAttention command sent to LoRa module: " + command);
  String response = "";
  unsigned long startMillis = millis();
  unsigned long timeout = 5000;
  while (millis() - startMillis < timeout) 
  {
    if (lora_serial.available()) 
    {
      response = lora_serial.readStringUntil('\n');
      break;
    }
  }
  Serial.println("Response is " + response) + "\n";
  return response;
}

void setup() 
{
  Serial.begin(115200);
  Serial.println("Setting up the module \n");
  lora_serial.begin(115200, SERIAL_8N1, RTLX_RX, RTLX_TX); 
  sendCommand("AT+ADDRESS=101");
  sendCommand("AT+NETWORKID=6");
  sendCommand("AT+BAND=868500000");
  sendCommand("AT+PARAMETER=7,9,1,7");
  sendCommand("AT+MODE=0");
  sendCommand("AT+CRFOP=15");
}

void loop() 
{
  sendCommand("AT+SEND=102,5,HELLO");
  delay(2000); 
  // while (Serial.available())
  // {
  //   int inByte = Serial.read();
  //   lora_serial.write(inByte);
  // }
  // while (lora_serial.available())
  // {
  //   Serial.println("Lora serial is available");
  //   String inByte = lora_serial.readStringUntil('\r\n');
  //   Serial.println(inByte);
  // }
}

EDIT 1

Currently I am using both NORVI modules based on REYAX. As both of these will have same instruction set. For sender side I am flashing the code to an esp32 based controller. For receiver I have connected the NORVI module to a serial to ttl converter and Python code is running for that device.

enter image description here enter image description here

Tahir
  • 1
  • 1

0 Answers0