Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site



Post a new topicPost a reply Page 1 of 1   [ 10 posts ]
Author Message
 Post subject: RN2483A loopback
PostPosted: Fri May 11, 2018 7:56 pm 

Joined: Wed May 09, 2018 10:51 pm
Posts: 5
I have 2 bundles with:
    Arduino uno
    multiprotocol radio shield
    RN2483A + antenna

I'm trying to make a set to test the range of RN2483A.
The goal is bundle A sends a packet to bundle B, Bundle B replyes to A, and bundle A counts how mucha packets recieved. I'm using the P2P mode.

The code of bundle A is

Code:
#include <Wire.h>

// Cooking API libraries
#include <arduinoUART.h>
#include <arduinoUtils.h>

// LoRaWAN library
#include <arduinoLoRaWAN.h>

// Pin definition for LoRaWAN module error LED:
const int error_led =  13;

//////////////////////////////////////////////
uint8_t socket = SOCKET1;
//////////////////////////////////////////////

// define radio settings
//////////////////////////////////////////////
int8_t power = 15;
uint32_t frequency = 868100000;
char spreading_factor[] = "sf12";
char coding_rate[] = "4/5";
uint16_t bandwidth = 125;
char crc_mode[] = "on";
//////////////////////////////////////////////


// define data to send
//char data[] = "01020304";

// variable
uint8_t error;

float test=10;
float sent=0;
float recieved=0;
   //int d=0;

void setup()
{
  //Radio P2P example - Sending packets
  pinMode(error_led, OUTPUT);
  digitalWrite(error_led, LOW);

  // module setup
  error = radioModuleSetup();
 
  // Check status
  if (error == 0)
  {
    //Module configured OK
    digitalWrite(error_led, LOW);
  }
  else
  {
    //Module configured ERROR"
    digitalWrite(error_led, HIGH);
  } 
}
void loop()
{
  // if(sent<=test){
if(true){
//Serial.print((sent/test));

 LoRaWAN.macPause();
   // Send packet
   error = LoRaWAN.sendRadio("0102030405");
   // Check status
   if (error == 0)
   {
      digitalWrite(error_led, LOW);
      //sent++;
      Serial.println("OK sen...");
     
      LoRaWAN.macPause();
      error = LoRaWAN.receiveRadio(1000000);
      if (error == 0)
      {
          //recieved++;
          Serial.println("OK rec...");
          digitalWrite(error_led, LOW);         
          // for (int i=0;i<LoRaWAN._length;i++){
           // Serial.print(char(LoRaWAN._buffer[i]));
          //}
          //Serial.println();
       }
       else{
          Serial.println("Er rec.......");
          digitalWrite(error_led, LOW);
       }
    }else
    {
      //Error waiting for packets. error
      digitalWrite(error_led, LOW);
      Serial.println("Er sen...");
    }
   
    Serial.println("------------------------");
   }
}
uint8_t radioModuleSetup()
{
  return status;
}


The code of bundle B is:

Code:

#include <Wire.h>

// Cooking API libraries
#include <arduinoUART.h>
#include <arduinoUtils.h>

// LoRaWAN library
#include <arduinoLoRaWAN.h>

// Pin definition for LoRaWAN module error LED:
const int error_led =  13;

//////////////////////////////////////////////
uint8_t socket = SOCKET1;
//////////////////////////////////////////////

// define radio settings
//////////////////////////////////////////////
uint8_t power = 15;
uint32_t frequency = 868100000;
char spreading_factor[] = "sf12";
char coding_rate[] = "4/5";
uint16_t bandwidth = 123;
char crc_mode[] = "on";
////////////////////////////////////5/////////

char data[] = "0102030405";
// variable
uint8_t error;


void setup()
{
  //Radio P2P example - Receiving packets
  pinMode(error_led, OUTPUT);
  digitalWrite(error_led, LOW);

  // module setup
  error = radioModuleSetup();
 
  // Check status
  if (error == 0)
  {
    //Module configured OK
    digitalWrite(error_led, LOW);
  }
  else
  {
    //Module configured ERROR
    digitalWrite(error_led, HIGH);
  } 
}


void loop()
{
 
  //Listening to packets...
  // rx
  LoRaWAN.macPause();
  error = LoRaWAN.receiveRadio(1000000);
  //error = LoRaWAN.receiveRadio(0);
  // Check status
  if (error == 0)
  {
    //--> Packet received
    //packet in LoRaWAN._buffer
    //length in LoRaWAN._length
    digitalWrite(error_led, LOW);
    // get SNR
    Serial.println("OK rec.........");
    for (int i=0;i<LoRaWAN._length;i++){
      Serial.print(char(LoRaWAN._buffer[i]));
    }
    Serial.println();
    //SNR in LoRaWAN._radioSNR
    //delay(200);
    LoRaWAN.macPause();
    //error = LoRaWAN.sendRadio(data);
    error = LoRaWAN.sendRadio("0102030405");
 
    // Check status
    if (error == 0)
    {
      Serial.println("OK Sent.......");
      //--> Packet sent OK
     digitalWrite(error_led, LOW);
      //  delay(150);
    }
    else
   {
      Serial.println("Er sen.......");
      //Error waiting for packets. error
      digitalWrite(error_led, LOW);
    }
  }
  else
  {
    //Error waiting for packets. error
    // error code
    //  1: error
    //  2: no incoming packet
        Serial.println("Er rec.......");
    digitalWrite(error_led, HIGH);
  }
 
    Serial.println("------------------------");
}


uint8_t radioModuleSetup()
{
}


When i run it, A can send to B, but B give me error when sendint to A.
How do i solve it?

PS: This code is adapted from your examples, i just deleted some parts to the post dont be so big


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Mon May 14, 2018 10:59 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi,

Please try to remove the serial prints of the code since rn2483 module communicates through the uart and it can be misconfigured if you uses the terminal. You can use a led to notify if the functions are working.

Regards


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Wed May 16, 2018 11:24 pm 

Joined: Wed May 09, 2018 10:51 pm
Posts: 5
I removed all serial prints, but now, how do i know if it really recieved the packet?


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Thu May 17, 2018 10:21 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi,

You can use a led to notify when the packets are received.

Regards


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Fri May 25, 2018 6:31 pm 

Joined: Wed May 09, 2018 10:51 pm
Posts: 5
Now i'm trying to comunicate between them with these settings but i can't

uint8_t power = 15;
uint32_t frequency = 868100000;
char spreading_factor[] = "sf12";
char coding_rate[] = "4/5";
uint16_t bandwidth = 250;
char crc_mode[] = "on";


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Mon May 28, 2018 9:27 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi,

Did you configure these setting in both modules? Do you get error when configuring any of the parameters? what is the distance between the devices?

Regards


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Mon May 28, 2018 10:18 am 

Joined: Wed May 09, 2018 10:51 pm
Posts: 5
The configs are the same, and i tryed several distances, from side by side to like 30 meters


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Tue May 29, 2018 8:25 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi,

Do you get error when configuring any of the parameters?

Does it work with bandwidth = 125 but not with bandwidth = 250?

Regards


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Thu May 31, 2018 12:06 am 

Joined: Wed May 09, 2018 10:51 pm
Posts: 5
i don't get errors, and it's like you said, i can comunicate on 125 but not on 250 or 500


Top
 Profile  
 
 Post subject: Re: RN2483A loopback
PostPosted: Thu May 31, 2018 9:37 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi,

Please try to decrease data rate or to increase the signal bandwidth (radio set rxbw 250).

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 10 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.