Changing DR manually

Hello, I am using RAK wisblock4630 and trying to change DR from webpage server side. I get fixed value of 2000690C which is for DR3 and this value is always fixed. I want to know how do I know the value for DR1,DR2, DR4, DR5 on arduino serial monitor. On webpage I can only change DR0 and DR5.

Welcome to the forum @zee_lodro

What firmware?
What BSP? RUI3 or open source Arduino?

What do you mean by “webpage server side”? The LoRaWAN server?

The datarate is either changed on the end node (RAK4630) or if ADR is enabled it can be automatically adjusted by the LNS.

1 Like

Thankyou. I have arduino ide and I am not using RUI3. Furthermore I want to control datarate from webpage for example if I select Dr2, it should be changed to DR2 at end node. Moreover I receive the hexadecimal data which is always constant and that is far Dr3. however other parameters such as snr, rssi keep changing but not dr data. Also I want to disable the ADR in this situation which I did.

  1. How can I change DR manually if adr is turned off. or receive equivalent mac command for DR1,2,3,4,5 as I have for DR3.
    here is function which is used for that data rx.
    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:%d”,
    app_data->port, app_data->buffsize, app_data->rssi, app_data->snr, app_data->buffer);
    }

I still don’t understand what you mean with

webpage server side

What webpage is that? What are you doing there?

I would like to change DR manually at node. before that I was wrong. In below code I can blink led if DR is 1 or 2 or 3 however now I want set DR1 or 2 or 3 depending on the last received byte and adr is disabled.

if (app_data->buffsize >= 2) {
// Get the last byte of the received data (assuming the data is little-endian)
lastReceivedByte = app_data->buffer[app_data->buffsize - 1];

  // Blink the LED based on the last received byte
  if (lastReceivedByte == 0x01) {
Serial.println("Changed to Data Rate DR1");
    // Blink LED1
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
  } else if (lastReceivedByte == 0x02) {
    // Blink LED2
   
    digitalWrite(LED_BUILTIN2, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN2, LOW);
    delay(500);
  } else if (lastReceivedByte == 0x03) {
    // Blink both LED1 and LED2
   
    digitalWrite(LED_BUILTIN, HIGH);
    digitalWrite(LED_BUILTIN2, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    digitalWrite(LED_BUILTIN2, LOW);
    delay(500);

You still didn’t tell me what firmware you are using.
Changing the datarate from the code side is different between Arduino opens source BSP and RUI3 BSP.

I am using Arduino open source BSP and using the example code of ABP. In this code it is possible that first I disable the ADR but I don’t know how to disable (is there any particular library or command to disable and enable adr). I have already used following libraries
#include <Arduino.h>
#include <LoRaWan-RAK4630.h>
#include <SPI.h>
#include <lmic.h>

and this code which did not work

LMIC_setAdrMode(LORAWAN_ADR_ON);
Serial.println(“ADR enabled.”);
} else {
LMIC_setAdrMode(LORAWAN_ADR_OFF);
Serial.println(“ADR disabled.”);

However can you please tell me how do I know about my firmware? I am using nrf module board RAK4630WisBlock.

You are mixing up library calls here. The SX126x-Arduino library has no API calls like LMIC_setAdrMode().

When using SX126x-Arduino library, the DR and ADR mode are set with

/**@brief Configure data rate
 *
 * @param data_rate data rate
 * @param enable_adr  enable adaptative data rate
 */
void lmh_datarate_set(uint8_t data_rate, bool enable_adr);

My first objective is to disable adr. later I know current data rate on serial monitor but how to use that for example if dr is 1 it should set dr1 etc. with lmh_datarateset I get error given below.

Further I receive this error. do I need to define myself this function.
lmh_get_current_datarate’ was not declared in this scope

I am using following libraries
#include <Arduino.h>
#include <LoRaWan-RAK4630.h>
#include <LoRaWan-Arduino.h>//http://librarymanager/All#SX126x
#include <SPI.h>

Thanks

The library doesn’t have such a function.