How to initiate the receive window?

Hi,
I am able to send downlink data from app sever.Please let me know how to initiate the receive window on the node(lorawan powered by raspberry pi)

By sending uplink data from your node which opens two receive-windows: RX1 and RX2, or by putting your node in Class-C (if it is capable of operating as a Class-C device) which will open a permanent RX2 receive window. Only after an uplink it will switch during one moment to RX1 (same as a Class-A device).

1 Like

Hi brocaar ,
I don’t have a gateway of my own so I am registering for the gateway of someone else.The gateway is 130 km far from here.Iam not sure if my end node(Lorawan with raspberry pi) can be supported as class-C device but on selecting supports device-C Iam getting the following error.

Please suggest me what to do

You know there is a message in the error :wink: Since you device never sent an uplink, the server does not know how to send a downlink back as it does not know the closest gateway to your device (stored in the RX Info).

Exactly brocaar,please let me know how to do send uplink data from the node.Please look at the code to send the data and let me know if any modifications are to be made

#include “arduPiLoRaWAN.h”

// socket to use
//////////////////////////////////////////////
uint8_t sock = SOCKET0;
//////////////////////////////////////////////

// Device parameters for Back-End registration
////////////////////////////////////////////////////////////
char DEVICE_EUI[] = “0102030405060708”;
char DEVICE_ADDR[] = “05060708”;
char NWK_SESSION_KEY[] = “01020304050607080910111213141516”;
char APP_SESSION_KEY[] = “000102030405060708090A0B0C0D0E0F”;
////////////////////////////////////////////////////////////

// Define port to use in Back-End: from 1 to 223
uint8_t PORT = 3;

// Define data payload to send (maximum is up to data rate)
char data[] = “0102030405060708090A0B0C0D0E0F”;
//I want to change the payload data to something else

// variable
uint8_t error;

void setup()
{
printf(“LoRaWAN example - Send Unconfirmed packets (no ACK)\n”);

printf("------------------------------------\n");
printf(“Module configuration\n”);
printf("------------------------------------\n\n");

//////////////////////////////////////////////
// 1. Switch on
//////////////////////////////////////////////

error = LoRaWAN.ON(sock);

// Check status
if( error == 0 )
{
printf(“1. Switch ON OK\n”);
}
else
{
printf(“1. Switch ON error = %d\n”, error);
}

//////////////////////////////////////////////
// 2. Set Device EUI
//////////////////////////////////////////////

error = LoRaWAN.setDeviceEUI(DEVICE_EUI);

// Check status
if( error == 0 )
{
printf(“2. Device EUI set OK\n”);
}
else
{
printf(“2. Device EUI set error = %d\n”, error);
}

//////////////////////////////////////////////
// 3. Set Device Address
//////////////////////////////////////////////

error = LoRaWAN.setDeviceAddr(DEVICE_ADDR);

// Check status
if( error == 0 )
{
printf(“3. Device address set OK\n”);
}
else
{
printf(“3. Device address set error = %d\n”, error);
}

//////////////////////////////////////////////
// 4. Set Network Session Key
//////////////////////////////////////////////

error = LoRaWAN.setNwkSessionKey(NWK_SESSION_KEY);

// Check status
if( error == 0 )
{
printf(“4. Network Session Key set OK\n”);
}
else
{
printf(“4. Network Session Key set error = %d\n”,error);
}

//////////////////////////////////////////////
// 5. Set Application Session Key
//////////////////////////////////////////////

error = LoRaWAN.setAppSessionKey(APP_SESSION_KEY);

// Check status
if( error == 0 )
{
printf(“5. Application Session Key set OK\n”);
}
else
{
printf(“5. Application Session Key set error = %d\n”, error);
}

//////////////////////////////////////////////
// 6. Save configuration
//////////////////////////////////////////////

error = LoRaWAN.saveConfig();

// Check status
if( error == 0 )
{
printf(“6. Save configuration OK\n”);
}
else
{
printf(“6. Save configuration error = %d\n”, error);
}

printf("\n------------------------------------\n");
printf(“Module configured\n”);
printf("------------------------------------\n\n");

LoRaWAN.getDeviceEUI();
printf(“Device EUI: %s\n”, LoRaWAN._devEUI);

LoRaWAN.getDeviceAddr();
printf(“Device Address: %s\n\n”, LoRaWAN._devAddr);
}

void loop()
{

//////////////////////////////////////////////
// 1. Switch on
//////////////////////////////////////////////

error = LoRaWAN.ON(sock);

// Check status
if( error == 0 )
{
printf(“1. Switch ON OK\n”);
}
else
{
printf(“1. Switch ON error = %d\n”, error);
}

//////////////////////////////////////////////
// 2. Join network
//////////////////////////////////////////////

error = LoRaWAN.joinABP();

// Check status
if( error == 0 )
{
printf(“2. Join network OK\n”);

//////////////////////////////////////////////
// 3. Send unconfirmed packet
//////////////////////////////////////////////

error = LoRaWAN.sendUnconfirmed(PORT, data);

// Error messages:
/*

  • ‘6’ : Module hasn’t joined a network
  • ‘5’ : Sending error
  • ‘4’ : Error with data length
  • ‘2’ : Module didn’t response
  • ‘1’ : Module communication error
    */
    // Check status
    if( error == 0 )
    {
    printf(“3. Send Unconfirmed packet OK\n”);
    if (LoRaWAN._dataReceived == true)
    {
    printf(" There’s data on port number %d.\r\n", LoRaWAN._port);
    printf(" Data: %s\n", LoRaWAN._data);
    }
    }
    else
    {
    printf(“3. Send Unconfirmed packet error = %d\n”, error);
    }
    }
    else
    {
    printf(“2. Join network error = %d\n”,error);
    }

//////////////////////////////////////////////
// 4. Clean channels
//////////////////////////////////////////////
error = LoRaWAN.reset();

// Reset channels
if( error == 0 )
{
printf(“4. Clean channels OK\n”);
}
else
{
printf(“4. Clean channels error = %d\n”, error);
}

//////////////////////////////////////////////
// 5. Switch off
//////////////////////////////////////////////
error = LoRaWAN.OFF(sock);

// Check status
if( error == 0 )
{
printf(“5. Switch OFF OK\n”);
}
else
{
printf(“5. Switch OFF error = %d\n”,error);
}

printf("\n");
delay(5000);
}

//////////////////////////////////////////////
// Main loop setup() and loop() declarations
//////////////////////////////////////////////

int main (){
setup();
while(1){
loop();
}
return (0);
}

Thanks for the reply.

I leave that as an exercise for you as I’m unable to review everybody’s node firmwares :slight_smile: Also you mentioned that you’re not close to a gateway, so this will be really hard to debug remotely. Given that the gateway is 130 km away, I would not count on it that it is able to receive your transmissions.

Thanks brocaar,
I am able to communicate with Lora waspmote gateway and Lora device(sx1272).I want to store the data received by the gateway into a database and analyse the data.Is there any possibility to implement this,as you see getting a LoraWAN is not easy in my place.

Please let me know if can give any idea into this.