Post a new topicPost a reply Page 1 of 1   [ 7 posts ]
Author Message
 Post subject: Arduino Uno & RN2483A
PostPosted: Mon Aug 20, 2018 7:54 am 

Joined: Fri Jun 22, 2018 10:11 am
Posts: 13
Hi there !

I’m trying to use a LoRaWAN module RN2483 with your code example on arduino uno but somehow the module isn't detected
I thought I could use a zigbee shield on it to use it but it’s not working. I tried without any shield by connecting Rx,Tx, Vdd, Gnd & reset pins to the arduino uno but I still can’t find the module with your arduino librairie.
I suppose my problem comes from the connection of the LoRaWAN module but I don’t know where to search about the pin mapping used in your library.

Any idea or advice will be appreciated ! Thank you !

AGirafe


Top
 Profile  
 
 Post subject: Re: Arduino Uno & RN2483A
PostPosted: Mon Aug 20, 2018 8:44 am 

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

We only supports LoRaWAN module to work with Arduino using the Multiprotocol board as it's showed in the tutorial.

Regards.


Top
 Profile  
 
 Post subject: Re: Arduino Uno & RN2483A
PostPosted: Mon Aug 20, 2018 9:02 am 

Joined: Fri Jun 22, 2018 10:11 am
Posts: 13
But may it work without it ? I mean it's just a shield, I thought I could connect it directly ...


Top
 Profile  
 
 Post subject: Re: Arduino Uno & RN2483A
PostPosted: Mon Aug 20, 2018 2:37 pm 

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

There is problems connecting directly the module to Arduino due to they work with different UART signals levels. It's possible but you should adapt the signals.

Regards.


Top
 Profile  
 
 Post subject: Re: Arduino Uno & RN2483A
PostPosted: Tue Aug 21, 2018 2:00 pm 

Joined: Fri Jun 22, 2018 10:11 am
Posts: 13
I'm now trying to use the LoRaWAN module on another arduino uC (ATmega328p) to have Rx & Tx to the right voltage (3.3V). I tried your exemple code (modified for debugging) to send something in P2P :
Code:
/*

#include <Wire.h>

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

// LoRaWAN library
#include <arduinoLoRaWAN.h>

#define rfpin A0

// Pin definition for LoRaWAN module error LED:
const int error_led =  5;
const int error_led2 =  6;

//////////////////////////////////////////////
uint8_t socket = SOCKET0;
//////////////////////////////////////////////

// define radio settings (P2P interface)
//////////////////////////////////////////////
uint8_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 LoRaWAN settings (LoRaWAN interface)
////////////////////////////////////////////////////////////
uint8_t PORT = 3;
char DEVICE_EUI[]  = "0102030405060708";
char DEVICE_ADDR[] = "05060708";
char NWK_SESSION_KEY[] = "01020304050607080910111213141516";
char APP_SESSION_KEY[] = "000102030405060708090A0B0C0D0E0F";
////////////////////////////////////////////////////////////

// define
char packet[256];
char data[20]="123456789ABCDEF0000";
// variable
uint8_t error;

/*LORAWAN_ANSWER_OK = 0,
   LORAWAN_ANSWER_ERROR = 1,
   LORAWAN_NO_ANSWER = 2,
   LORAWAN_INIT_ERROR = 3,
   LORAWAN_LENGTH_ERROR = 4,
   LORAWAN_SENDING_ERROR = 5,
   LORAWAN_NOT_JOINED = 6,
   LORAWAN_INPUT_ERROR = 7,
LORAWAN_VERSION_ERROR = 8*/

void setup()
{
  //P2P to LoRaWAN gateway
  pinMode(rfpin, OUTPUT);
  digitalWrite(rfpin, HIGH);
 
  pinMode(error_led, OUTPUT);
  pinMode(error_led2, OUTPUT);
 
  digitalWrite(error_led, HIGH);
  digitalWrite(error_led2, HIGH);
  delay(1000);
  digitalWrite(error_led, LOW);
  digitalWrite(error_led2, LOW);
 
  // module setup for LoRaWAN
  /*error = lorawanModuleSetup();

  // Check status
  if (error == 0)
  {
    //LoRaWAN interface configured OK
    digitalWrite(error_led, LOW);
  }
  else
  {
    //LoRaWAN interface configured ERROR
    //digitalWrite(error_led, HIGH);
  }*/

  // module setup
  error = radioModuleSetup();

  // Check status
 

}


void loop()
{
    // Packets to send
    //LoRaWAN.macPause();
   
    error= LoRaWAN.sendRadio(data);
   
   
  delay (1000);
  //-------------------------------------------------------
  //Listening to packets:
  //-------------------------------------------------------

  // Set receive mode
  //error = LoRaWAN.receiveRadio(10000);

    //   // Check status
    //   if (error == 0)
    //   {
    //     //--> Packet received

    //     //data in LoRaWAN._buffer
    //     //length in LoRaWAN._length

    //     // copy packet contents into a global buffer
    //     // strncpy( packet, (char*) LoRaWAN._buffer, sizeof(packet));

    //     //-------------------------------------------------------
    //     //Route data to LoRaWAN gateway:
    //     //-------------------------------------------------------

    //     // switch to LoRaWAN mode
    //     //LoRaWAN.macResume();

    //     // join
    //     //error = LoRaWAN.joinABP();

    //     // Check status
    //     // if( error == 0 )
    //     // {
    //     //   //Join network OK
    //     // //digitalWrite(error_led, LOW);
    //     // }
    //     // else
    //     // {
    //     //   //Join network error
    //     // //digitalWrite(error_led, HIGH);
    //     // }


    //     // send received packet to LoRaWAN gateway
    //     // error = LoRaWAN.sendConfirmed(PORT, packet);

    //     // Check status
    //     // if( error == 0 )
    //     // {
    //     //   //Send Confirmed packet OK
    //     //   //digitalWrite(error_led, LOW);
    //     // }
    //     // else
    //     // {
    //     //   //Send Confirmed packet error
    //     //   //digitalWrite(error_led, HIGH);
    //     // }

    //     // module setup
    //     // error = lorawanModuleSetup();

    //     // Check status
    //     // if (error == 0)
    //     // {
    //     //   //LoRaWAN interface configured OK
    //     //   //digitalWrite(error_led, LOW);
    //     // }
    //     // else
    //     // {
    //     //   //LoRaWAN interface configured ERROR
    //     //   //digitalWrite(error_led, HIGH);
    //     // }

    //     // module setup
    //    // error = radioModuleSetup();

    //     // Check status
    //     // if (error == 0)
    //     // {
    //     //   //Radio interface configured OK
    //     //   //digitalWrite(error_led, LOW);
    //     // }
    //     // else
    //     // {
    //     //   //Radio interface configured ERROR
    //     //   //digitalWrite(error_led, HIGH);
    //     // }

    //   }
    //   else
    //   {
    //     // error code
    //     //  1: error
    //     //  2: no incoming packet
    //     //Error waiting for packets. error
    //     //digitalWrite(error_led, LOW);
    //   }
   // while(1);
}




/***********************************************************************************
*
* radioModuleSetup()
*
*   This function includes all functions related to the module setup and configuration
*   The user must keep in mind that each time the module powers on, all settings are set
*   to default values. So it is better to develop a specific function including all steps
*   for setup and call it everytime the module powers on.
*
*
***********************************************************************************/
uint8_t radioModuleSetup()
{

  uint8_t status = 0;
  uint8_t e = 0;

  //////////////////////////////////////////////
  // 1. switch on
  //////////////////////////////////////////////

  e = LoRaWAN.ON(socket);
 
 
  // Check status
  if (e == 0)
  {
    //1. Switch ON OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //1. Switch ON error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }
  //-------------------------------------------------------

  //while(1);

  //////////////////////////////////////////////
  // 2. Enable P2P mode
  //////////////////////////////////////////////

  e = LoRaWAN.macPause();
  //digitalWrite(error_led, HIGH);
 
  // Check status
  if (e == 0)
  {
    //2. P2P mode enabled OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //2. Enable P2P mode error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }
  //-------------------------------------------------------



  //////////////////////////////////////////////
  // 3. Set/Get Radio Power
  //////////////////////////////////////////////

  // Set power
  e = LoRaWAN.setRadioPower(power);

  // Check status
  if (e == 0)
  {
    //3.1. Set Radio Power OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //3.1. Set Radio Power error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }
 
  // Get power
  e = LoRaWAN.getRadioPower();

  // Check status
  if (e == 0)
  {
    //3.2. Get Radio Power OK.
    //"Power in LoRaWAN._radioPower
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //3.2. Get Radio Power error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }
  //-------------------------------------------------------


  //////////////////////////////////////////////
  // 4. Set/Get Radio Frequency
  //////////////////////////////////////////////

  // Set frequency
  e = LoRaWAN.setRadioFreq(frequency);

  // Check status
  if (e == 0)
  {
    //4.1. Set Radio Frequency OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //4.1. Set Radio Frequency error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }



  // Get frequency
  e = LoRaWAN.getRadioFreq();

  // Check status
  if (e == 0)
  {
    //4.2. Get Radio Frequency OK
    //Frequency in LoRaWAN._radioFreq
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //4.2. Get Radio Frequency error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }
  //-------------------------------------------------------
 


  //////////////////////////////////////////////
  // 5. Set/Get Radio Spreading Factor (SF)
  //////////////////////////////////////////////

  // Set SF
  e = LoRaWAN.setRadioSF(spreading_factor);

  // Check status
  if (e == 0)
  {
    //5.1. Set Radio SF OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //5.1. Set Radio SF error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }

  // Get SF
  e = LoRaWAN.getRadioSF();

  // Check status
  if (e == 0)
  {
    //5.2. Get Radio SF OK
    //Spreading Factor in LoRaWAN._radioSF
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //5.2. Get Radio SF error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }
  //-------------------------------------------------------

 

  //////////////////////////////////////////////
  // 6. Set/Get Radio Coding Rate (CR)
  //////////////////////////////////////////////

  // Set CR
  e = LoRaWAN.setRadioCR(coding_rate);

  // Check status
  if (e == 0)
  {
    //6.1. Set Radio CR OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //6.1. Set Radio CR error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }
 

 

  // Get CR
  e = LoRaWAN.getRadioCR(); // BUG ICI : LORAWAN_ANSWER_ERROR

  // Check status
  if (e == 0)
  {
    //6.2. Get Radio CR OK.
    //Coding Rate in LoRaWAN._radioCR
    //digitalWrite(error_led, LOW);
  }
  else
  {
    if (e==1)
    {
        //6.2. Get Radio CR error
       
        status = 1;
    }
    else if (e==2)
    {
     
    }
  }
  //-------------------------------------------------------

  digitalWrite(error_led2, HIGH);
  while(1);

  //////////////////////////////////////////////
  // 7. Set/Get Radio Bandwidth (BW)
  //////////////////////////////////////////////

  // Set BW
  e = LoRaWAN.setRadioBW(bandwidth);

  // Check status
  if (e == 0)
  {
    //7.1. Set Radio BW OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //7.1. Set Radio BW error
    digitalWrite(error_led, HIGH);
  }

  // Get BW
  e = LoRaWAN.getRadioBW();

  // Check status
  if (e == 0)
  {
    //7.2. Get Radio BW OK.
    //Bandwidth in LoRaWAN._radioBW
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //7.2. Get Radio BW error
    digitalWrite(error_led, HIGH);
    status = 1;
  }
  //-------------------------------------------------------
 

  //////////////////////////////////////////////
  // 8. Set/Get Radio CRC mode
  //////////////////////////////////////////////

  // Set CRC
  e = LoRaWAN.setRadioCRC(crc_mode);

  // Check status
  if (e == 0)
  {
    //8.1. Set Radio CRC mode OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //8.1. Set Radio CRC mode error
    digitalWrite(error_led, HIGH);
    status = 1;
  }

  // Get CRC
  e = LoRaWAN.getRadioCRC();

  // Check status
  if (e == 0)
  {
    //8.2. Get Radio CRC mode OK.
    //CRC status in LoRaWAN._crcStatus
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //8.2. Get Radio CRC mode error
    digitalWrite(error_led, HIGH);
    status = 1;
  }
  //-------------------------------------------------------

 
  return status;
}







/***********************************************************************************
 *
 * lorawanModuleSetup()
 *
 *   This function includes all functions related to the module setup for LoRaWAN
 *   performance.
 *
 *
 ***********************************************************************************/
uint8_t lorawanModuleSetup()
{

  uint8_t status = 0;
  uint8_t e = 0;


  //-------------------------------------------------------
  //LoRaWAN mode configuration:
  //-------------------------------------------------------

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

  e = LoRaWAN.ON(socket);

  // Check status
  if( e == 0 )
  {
    //1. Switch ON OK"
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //1. Switch ON error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }

  LoRaWAN.factoryReset();

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

  e = LoRaWAN.setDeviceEUI(DEVICE_EUI);

  // Check status
  if( e == 0 )
  {
    //2.1. Device EUI set OK"));
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //2.1. Device EUI set error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }


  e = LoRaWAN.getDeviceEUI();

  // Check status
  if( e == 0 )
  {
    //2.2. Device EUI get OK.
    //Device EUI in LoRaWAN._devEUI
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //2.2. Device EUI get error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }


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

  e = LoRaWAN.setDeviceAddr(DEVICE_ADDR);

  // Check status
  if( e == 0 )
  {
    //3.1. Device address set OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //3.1. Device address set error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }

  e = LoRaWAN.getDeviceAddr();

  // Check status
  if( e == 0 )
  {
    //3.2. Device address get OK.
    //Device address is LoRaWAN._devAddr
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //3.2. Device address get error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }


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

  error = LoRaWAN.setNwkSessionKey(NWK_SESSION_KEY);

  // Check status
  if( error == 0 )
  {
    //4. Network Session Key set OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //4. Network Session Key set error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }


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

  error = LoRaWAN.setAppSessionKey(APP_SESSION_KEY);

  // Check status
  if( error == 0 )
  {
    //5. Application Session Key set OK"
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //5. Application Session Key set error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }


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

  error = LoRaWAN.saveConfig();

  // Check status
  if( error == 0 )
  {
    //6. Save configuration OK
    //digitalWrite(error_led, LOW);
  }
  else
  {
    //6. Save configuration error
    //digitalWrite(error_led, HIGH);
    status = 1;
  }

  //-------------------------------------------------------

  return status;
}
            


I commented some of the code and there is a while (1) in the radioModule function to ensure there it won't going further.
With LED I identified the problem was at the e = LoRaWAN.getRadioCR(); function.
I identified in the library that it was a reponse problem of the module. I can get here (line of char* pch = strtok((char*)_buffer,"\r\n");):
Code:
uint8_t arduinoLoRaWAN::getRadioCR()
{
    uint8_t status;
    char ans1[15];
      pinMode(error_led, OUTPUT);
  pinMode(error_led2, OUTPUT);
   
    memset(_command,0x00,sizeof(_command));
    memset(ans1,0x00,sizeof(ans1));
   
    // create "radio get cr" command
    sprintf_P(_command,(char*)pgm_read_word(&(table_LoRaWAN_COMMANDS[62])));
    // create "invalid_param" answer
    sprintf_P(ans1,(char*)pgm_read_word(&(table_LoRaWAN_ANSWERS[1])));
   
    //send command and wait for ans
    status = sendCommand(_command,(char *)"\r\n",ans1,100);
   
    if (status == 1)
    {
       char* pch = strtok((char*)_buffer,"\r\n");
        if (pch != NULL)
        {
            memset(_radioCR, 0x00, sizeof(_radioCR));
            strncpy(_radioCR, pch, sizeof(_radioCR));
            return LORAWAN_ANSWER_OK;
        }
        else
        {
            digitalWrite(error_led, HIGH);
            return LORAWAN_ANSWER_ERROR;
        }
    }
    else if (status == 2)
    {
        return LORAWAN_ANSWER_ERROR;
       
    }
    else
    {
        return LORAWAN_NO_ANSWER;
    }
}


As I understand it, the command is sent and i get an answer containing "\r\n" but apparently it's "NULL"...
Any idea why I get this error right at this function ? the previous function used in the radioModuleSetup function are working (no error return), I don't why it's not working only on this function :-/.

Thank's a lot for your help !


Top
 Profile  
 
 Post subject: Re: Arduino Uno & RN2483A
PostPosted: Wed Aug 22, 2018 9:18 am 

Joined: Fri Jun 22, 2018 10:11 am
Posts: 13
Additional information : I removed the function in question in the init and everything works correctly..

I really don't understand why there's an error only there.

I tested the module on a waspmote and I don't get any error :-/


Top
 Profile  
 
 Post subject: Re: Arduino Uno & RN2483A
PostPosted: Mon Aug 27, 2018 12:43 pm 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11304
The function for Arduino and Waspmote are exactly the same so we don't know what is happening. We recommend you to test with an Arduino UNO and a multiprotocol shield.

Sorry we couldn't give a better support to solve the issue.

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 7 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:


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.