RAK11300 downlink messages from TTN

Hi friends, Please someone that can give me support, I need to send a downlink message from TTN LNS, and I want activate a relay, if someone has a example of sketch to RAK11300 module in Arduino IDE, how to receive information in the Module.

thanks in advance.

Lenin Morejon

Hi @lmorejon ,

You can use the example sketch of LoRaWAN_OTAA_ABP in RAK11300. Then modify the lorawan_rx_handler.

Something like this:

void lorawan_rx_handler(lmh_app_data_t *app_data)
{
  Serial.printf("LoRa Packet received on port %d, size:%d, rssi:%d, snr:%d, data:%s\n",
                app_data->port, app_data->buffsize, app_data->rssi, app_data->snr, app_data->buffer);
  uint8_t relay_command = *app_data->buffer;
  if(relay_command==1)
  {
    Serial.println("LED on");  
    // Make relay on here
  }
  else
  {
    Serial.println("LED off");
    // Make relay off here
  }
}

As you see here, I added the variable relay_command. In this sketch, sending value 0x01 will turn on the LED. Then, any other value will turn if off.

Thank you very much Carl, now with that example I can send messages downlink to my Board with RAK11300 module, I will be showing the PCB reading to energy meter with several electric parameters and doing actions to cut electrical service and re connect the electrical service.

best kind regards

Lenin Morejon

Hi Carl, thank you very much to your support.

I am sending information to LNS (TTI), but I am facing that issue:

When I try to send that frame:
01A203020100A305A103020107E60918060D2114000000000000012C000000000000000000000000000001900000005C000000000000000000002E1800000000000003E80000177300000000
That frame contains all information from energy meter, but I am not send the frame whole, I have to cut the frame for example: 01A203020100A305A103

when I try to send 10 or more bytes I got error:
lmh_send fail count 8
Sending frame now…
lmh_send fail count 9
Sending frame now…
lmh_send fail count 10
Sending frame now…
lmh_send fail count 11

when I cut the frame I got success:
Sending frame now…
lmh_send ok count 13
TX finished
Sending frame now…
lmh_send ok count 14
TX finished
Sending frame now…
lmh_send ok count 15
TX finished

I am using the method in the example sending: Hello!

uint32_t i = 0;
memset(m_lora_app_data.buffer, 0, LORAWAN_APP_DATA_BUFF_SIZE);
m_lora_app_data.port = gAppPort;
m_lora_app_data.buffer[i++] = ‘H’;
m_lora_app_data.buffer[i++] = ‘e’;
m_lora_app_data.buffer[i++] = ‘l’;
m_lora_app_data.buffer[i++] = ‘l’;
m_lora_app_data.buffer[i++] = ‘o’;
m_lora_app_data.buffer[i++] = ‘!’;
m_lora_app_data.buffsize = i;

I tried to send several Hello! example: Hello!Hello!Hello!, using that same method but I got error. Why?

How much information can I send by LoraWAN?
Please, can you give your help again?
thank you very much
Lenin Morejon

@lmorejon
The max packet size you can send depends on

  • LoRaWAN region
  • Selected data rate

You can find both information in our Documentation Center

For the send error, it can have multiple sources.
How often do you try to send the message?
Is ADR enabled?
Which example code are you using? The one that is coming with the Arduino BSP or the example from our WisBlock Github repo

Hi BeeGee.

Solved …the DR was in the firmware with DR_0 …I placed DR_3, now I am sending frames longer.

thanks a lot.

Lenin Morejon

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.