Recieving downlink messages from LNS on Grove Wio-e5

Hi, i am a student doing a first time project with LoRaWAN.

I have a LoRaWAN Network Server(LNS) running in docker, a gateway module (WM1302) with a Pi-hat on a rpi-3b and a Wio Grove-e5 Module connected to an Arduino Uno R3.
For a project i’m doing i would like to queue a message in the LNS and receive/read the message on the Arduino end node. I read online that this should be possible to do.

  • I have setup the network and connected the devices to it.
  • I can send an AT+MSGHEX=“payload” to the LNS and see it in the LoRaWAN frames tab.
  • The Arduino end node in configures to Class C and both the RXWIN1 and RXWIN2 are compliant with the EU region.

but when i try to queue a message to the Arduino i don’t read it there in the serial monitor.

for example:

  • I queue “48656C6C6F”, confirmed on FPORT 8
  • A new TXACK event appears in the event tab with downlinkId:2319993945
  • I check the logs on the gateway to see if it is received:
root@chirpstack:~# logread | grep "2319993945"
Tue Feb  4 14:01:38 2025 user.info chirpstack-mqtt-forwarder[3137]: Received downlink command, downlink_id: 2319993945, topic: eu868/gateway/0016c001f1050e73/command/down
Tue Feb  4 14:01:38 2025 user.info chirpstack-mqtt-forwarder[3137]: Sending downlink frame, downlink_id: 2319993945
Tue Feb  4 14:01:38 2025 user.info chirpstack-concentratord-sx1302[2091]: Enqueueing immediate packet, downlink_id: 2319993945, current_counter_us: 3996888924
Tue Feb  4 14:01:38 2025 user.info chirpstack-mqtt-forwarder[3137]: Received ack, items: ["OK"], downlink_id: 2319993945
Tue Feb  4 14:01:38 2025 user.info chirpstack-mqtt-forwarder[3137]: Sending ack event, downlink_id: 2319993945, topic: eu868/gateway/0016c001f1050e73/event/ack
Tue Feb  4 14:01:39 2025 user.info chirpstack-concentratord-sx1302[2091]: Scheduled packet for TX, downlink_id: 2319993945, count_us: 3997888924, freq: 869525000, bw: 125000, mod: LoRa, dr: SF12

i am using this sketch on the Arduino

#include <SoftwareSerial.h>

// Setup SoftwareSerial for the Wio-E5 module.
SoftwareSerial wioSerial(11, 10); // RX, TX

// Timeouts and delays (adjust as needed)
const unsigned long joinTimeout    = 15000;  // Maximum time (in ms) to wait for join messages
const unsigned long postDoneDelay  = 1000;   // Delay after "Done" to ensure join confirmation
const unsigned long retryDelay     = 2000;   // Delay between join attempts

// Forward declarations
String sendATCommandAndWait(String command, unsigned long timeoutMS = 300);
void joinNetwork();
void flushSerial();

void setup() {
  Serial.begin(9600);       // Monitor Serial
  wioSerial.begin(9600);     // Wio‑E5 baud rate
  delay(1000);
  
  Serial.println("Initializing Wio‑E5...");
  
  // Set log to quiet (optional) and switch to Class C mode.
  flushSerial();
  sendATCommandAndWait("AT+LOG=LOG", 300);
  delay(100);
  sendATCommandAndWait("AT+CLASS=C, SAVE", 500);
  delay(100);
  
  // Join the network (for OTAA, if needed).
  joinNetwork();
  delay(1000);
  sendATCommandAndWait("AT+CMSGHEX=\"48656C6C6F\"", 1000);
    while (wioSerial.available()) {
    char c = wioSerial.read();
    Serial.write(c);  // Directly output the character to the Serial Monitor.
  }
  //delay(2500);
  //Serial.println("Configuration complete. Now listening for downlink messages...");
}

void loop() {
  // Instead of reading by line, read character-by-character:
  while (wioSerial.available()) {
    char c = wioSerial.read();
    Serial.write(c);  // Directly output the character to the Serial Monitor.
  }
  // A short delay can help avoid overwhelming the loop.
  //delay(5);
}

I’m not sure what i am doing wrong. Feel free to reply if i left out any important information. Hopefully my peers can point me in the right direction. Thanks a lot in advance.

As addition to my troubleshooting. When i re-opened the serial monitor, the AT+CMSG command got executed, which cause a message to be send to the LNS. Curiously, after sending the message i was able to receive a downlink message from the LNS. See the log below:

13:54:23.911 -> Sending: AT+LOG=DEBUG
13:54:24.223 -> Raw response: +LOG: DEBUG
13:54:24.223 -> 
13:54:24.300 -> Sending: AT+CLASS=?
13:54:24.804 -> Raw response: +CLASS: C
13:54:24.840 -> 
13:54:24.922 -> Attempting to join network...
13:54:24.955 -> Received: +JOIN: Joined already
13:54:25.938 -> Joined network successfully.
13:54:26.967 -> Sending: AT+CMSGHEX="48656C6C6F"
13:54:27.966 -> Raw response: +LOG:  WARN 16154586 LW      tx 8, 48656C6C6F(5)
13:54:28.031 -> +CMSGHEX: Start
13:54:28.064 -> +CMSGHEX: Wait ACK
13:54:28.097 -> +LOG: DEBUG 16154587 LW      ch 04
13:54:28.129 -> +LOG: DEBUG 16154587 LORA    TX, 867300000, SF7, 125KHz, 8, 2
13:54:28.195 -> +LOG: DEBUG 16154587 LORA    TX, 801D2D8201A0070008D142224036C4016238
13:54:28.261 -> +LOG: DEBUG 16154643 LORA    RX, 869525000, SF12, 125KHz, 0
13:54:28.326 -> 
13:54:28.326 -> +LOG: DEBUG 16155634 LORA    RX, 867300000, SF7, 125KHz, 24
13:54:28.392 -> +LHEX: FPENDING
13:54:28.424 -> +CMSGHEX: ACK Received
13:54:28.424 -> +CMSGHEX: PORT: 8; RX: "74657374"
13:54:28.457 -> +CMSGHEX: RXWIN1, RSSI -22, SNR 9.0
13:54:28.531 -> +CMSGHEX: Done
13:54:30.419 -> +LOG: DEBUG 16157994 LORA    RX, A01D2D8201A0080008E43E1729ED9C5577, -11, 5
13:54:30.490 -> +LOG: DEBUG 16157999 LORA    RX, 869525000, SF12, 125KHz, 0
13:56:18.303 -> +LOG: DEBUG 16265908 LORA    RX, 60F7C12A1420B20000976C0291C7, -101, -13
13:56:18.413 -> +LOG: DEBUG 16265912 LORA    RX, 869525000, SF12, 125KHz, 0

This behaviour i would expect when i set my LoRa module to class A, which would open a windows for downlinks to be received. But as the logs show my module is set to class C after asking the state of it. But it still behaves like it would in class A. I am not able to receive messages any more after this. Only when i recreate this specific scenario. hope this additional info is useful.