Random message loss on RAK7431

Hello, recently I have been having problems with my RAK7431, I have two of them. I am sending relatively small payloads every 5 minutes and there are a lot of messages that are getting lost.
My configuration in TTN is as follows:


The hardware I use is the following:
Gateway: RAK7249 | EG-95-NA | US915 | 16 channels
I have a 3dbi fiberglass antenna on the bridge and two antennas on the gateway (one 3dbi in LoRa and one 5.8dbi in LoRa2)
Bridge: RAK7431 | US915 | Class C

The distance between Gateway and the bridge is approximately 15 meters.

It seems that this problem is common among different users, please let me know if someone already found a solution.

Thanks.

Hello @Dacsystems , Welcome to RAKWireless Forum.

Please check LoRaWAN US915

Maybe you need to add channel mask to end device application.

Hi, @marcio thanks for your reply.

I don’t understand what kind of mask I need to add, reading the documents you send me it seems that the channel mask just enables some of the 64 available channels in 915US region. In RAK7431 there is not an option to change the mask but I can add or remove channels, currently, the device is working with 8 different channels, from 8 to 15 (as I understand this is FSB2 which is already in my app configuration) so, your suggestion is to change FSB2 to another? Or just delete/add channels to the default configuration? the current mask is “000000000000FF00”. Also, I am trying to increase the number of messages (scheduled poll tasks) per node and the message loss gets even worst, but I found out that with 10 minutes gap between messages (two 12 bytes messages + overhead) everything works fine. Problems came when adding more messages to the poll task or decreasing the poll period (eg. 5 minutes)
The data length of each message is 12 bytes + message overhead (non-transparent mode).

I think I have around two months of dealing with this situation with no luck, I don’t know if this is a factory problem or I am just doing something wrong with my config so I will really appreciate knowing the most I can about possible solutions (firmware upgrade, quick fixes, additional configuration, etc.) for sure I will try every suggestion.

Thanks for your reply!

Hello @Dacsystems ,

The problem is in the end device application not in the gateway.

One more example now on heltec AU915 also goes for US915.

LoRaWAN example Sub-Band usage (AU915) — Heltec Automation Docs V0.0.1 documentation (heltec-automation-docs.readthedocs.io)

Hello @Dacsystems ,
This RAK3172 guide is not online yet.


The complete sketch

Blockquote

#define OTAA_PERIOD (20000)
/*************************************

LoRaWAN band setting:
RAK_REGION_EU433
RAK_REGION_CN470
RAK_REGION_RU864
RAK_REGION_IN865
RAK_REGION_EU868
RAK_REGION_US915
RAK_REGION_AU915
RAK_REGION_KR920
RAK_REGION_AS923

*************************************/
#define OTAA_BAND (RAK_REGION_US915)
#define OTAA_DEVEUI {0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x04, 0xF1, 0xC0}
#define OTAA_APPEUI {0x70, 0xB3, 0xD5, 0x7E, 0xD0,0x03, 0xAB, 0xA2}
#define OTAA_APPKEY {0xB4, 0x85, 0x7E, 0xFE, 0x1C, 0xB5, 0x15, 0xEB, 0x44, 0x61, 0x0D, 0x9B, 0x20, 0x6A, 0xF3, 0x3A}

/** Packet buffer for sending */
uint8_t collected_data[64] = { 0 };

void recvCallback(SERVICE_LORA_RECEIVE_T * data)
{
if (data->BufferSize > 0) {
Serial.println(“Something received!”);
for (int i = 0; i < data->BufferSize; i++) {
Serial.printf("%x", data->Buffer[i]);
}
Serial.print("\r\n");
}
}

void joinCallback(int32_t status)
{
Serial.printf(“Join status: %d\r\n”, status);
}

void sendCallback(int32_t status)
{
if (status == 0) {
Serial.println(“Successfully sent”);
} else {
Serial.println(“Sending failed”);
}
}

void setup()
{
Serial.begin(115200, RAK_AT_MODE);

Serial.println(“RAKwireless LoRaWan OTAA Example”);
Serial.println("------------------------------------------------------");

// OTAA Device EUI MSB first
uint8_t node_device_eui[8] = OTAA_DEVEUI;
// OTAA Application EUI MSB first
uint8_t node_app_eui[8] = OTAA_APPEUI;
// OTAA Application Key MSB first
uint8_t node_app_key[16] = OTAA_APPKEY;

if (!api.lorawan.appeui.set(node_app_eui, 8)) {
Serial.printf(“LoRaWan OTAA - set application EUI is incorrect! \r\n”);
return;
}
if (!api.lorawan.appkey.set(node_app_key, 16)) {
Serial.printf(“LoRaWan OTAA - set application key is incorrect! \r\n”);
return;
}
if (!api.lorawan.deui.set(node_device_eui, 8)) {
Serial.printf(“LoRaWan OTAA - set device EUI is incorrect! \r\n”);
return;
}

if (!api.lorawan.band.set(OTAA_BAND)) {
Serial.printf(“LoRaWan OTAA - set band is incorrect! \r\n”);
return;
}
uint16_t maskBuff = 0x0002;
if (!api.lorawan.mask.set(&maskBuff)) {
Serial.printf(“LoRaWan OTAA - set mask is incorrect! \r\n”);
return;
}

if (!api.lorawan.deviceClass.set(RAK_LORA_CLASS_A)) {
Serial.printf(“LoRaWan OTAA - set device class is incorrect! \r\n”);
return;
}
if (!api.lorawan.njm.set(RAK_LORA_OTAA)) // Set the network join mode to OTAA
{
Serial.printf
(“LoRaWan OTAA - set network join mode is incorrect! \r\n”);
return;
}
if (!api.lorawan.join()) // Join to Gateway
{
Serial.printf(“LoRaWan OTAA - join fail! \r\n”);
return;
}

/** Wait for Join success */
while (api.lorawan.njs.get() == 0) {
Serial.print(“Wait for LoRaWAN join…”);
api.lorawan.join();
delay(10000);
}

if (!api.lorawan.adr.set(true)) {
Serial.printf
(“LoRaWan OTAA - set adaptive data rate is incorrect! \r\n”);
return;
}
if (!api.lorawan.rety.set(1)) {
Serial.printf(“LoRaWan OTAA - set retry times is incorrect! \r\n”);
return;
}
if (!api.lorawan.cfm.set(1)) {
Serial.printf(“LoRaWan OTAA - set confirm mode is incorrect! \r\n”);
return;
}

/** Check LoRaWan Status*/
Serial.printf(“Duty cycle is %s\r\n”, api.lorawan.dcs.get()? “ON” : “OFF”); // Check Duty Cycle status
Serial.printf(“Packet is %s\r\n”, api.lorawan.cfm.get()? “CONFIRMED” : “UNCONFIRMED”); // Check Confirm status
uint8_t assigned_dev_addr[4] = { 0 };
api.lorawan.daddr.get(assigned_dev_addr, 4);
Serial.printf(“Device Address is %02X%02X%02X%02X\r\n”, assigned_dev_addr[0], assigned_dev_addr[1], assigned_dev_addr[2], assigned_dev_addr[3]); // Check Device Address
Serial.printf(“Uplink period is %ums\r\n”, OTAA_PERIOD);
Serial.println("");
api.lorawan.registerRecvCallback(recvCallback);
api.lorawan.registerJoinCallback(joinCallback);
api.lorawan.registerSendCallback(sendCallback);
}

void uplink_routine()
{
/** Payload of Uplink */
uint8_t data_len = 0;
collected_data[data_len++] = (uint8_t) ‘t’;
collected_data[data_len++] = (uint8_t) ‘e’;
collected_data[data_len++] = (uint8_t) ‘s’;
collected_data[data_len++] = (uint8_t) ‘t’;

Serial.println(“Data Packet:”);
for (int i = 0; i < data_len; i++) {
Serial.printf(“0x%02X “, collected_data[i]);
}
Serial.println(””);

/** Send the data package */
if (api.lorawan.send(data_len, (uint8_t *) & collected_data, 2, true, 1)) {
Serial.println(“Sending is requested”);
} else {
Serial.println(“Sending failed”);
}
}

void loop()
{
static uint64_t last = 0;
static uint64_t elapsed;

if ((elapsed = millis() - last) > OTAA_PERIOD) {
uplink_routine();

last = millis();

}
//Serial.printf(“Try sleep %ums…”, OTAA_PERIOD);
api.system.sleep.all(OTAA_PERIOD);
//Serial.println(“Wakeup…”);
}

Blockquote