LoRAWAN and UART

Wireless communications in Waspmote, topologies, node types...
Post Reply
samimd19
Posts: 19
Joined: Wed Feb 21, 2018 10:14 am
Company: Saint Gobain Sekurit

LoRAWAN and UART

Post by samimd19 » Thu May 17, 2018 9:27 am

Hi,
Is it possible to take UART values and send it over LoRaWAN module?

samimd19
Posts: 19
Joined: Wed Feb 21, 2018 10:14 am
Company: Saint Gobain Sekurit

Re: LoRAWAN and UART

Post by samimd19 » Thu May 17, 2018 12:10 pm

I am trying to extract values from UART which is connected to a rduino and then send the data using LoRaWAN. I am not being able to do it, which i could do using Xbee868LP.

Code: Select all

#include <WaspLoRaWAN.h>

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

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


// define data to send
char data[] = "0102030405060708090A0B0C0D0E0F";



// variable
uint8_t error;


void setup() 
{
  USB.ON();
  USB.println(F("Radio P2P example - Sending packets\n"));

  // module setup
  error = radioModuleSetup();
  
  // Check status
  if (error == 0)
  {
    USB.println(F("Module configured OK"));     
  }
  else 
  {
    USB.println(F("Module configured ERROR"));     
  }  

}


void loop() 
{   ////////////////////////////////////////
    // Taking value from UART
    ////////////////////////////////////////
    char message[20];
    char checkl[20]="20";
    while(!serialAvailable(1))
    {
       //wait for available
    }
    strcpy( message, "" );
    while (serialAvailable(1) > 0)
    {
        int val = serialRead(1);
        //USB.print(val,BYTE);
        snprintf(message, sizeof(message),"%s%c", message,val);
     }
     //USB.println();

     USB.print(message);
  // Send packet
  error = LoRaWAN.sendRadio(message);
  
  // Check status
  if (error == 0)
  {
    USB.println(F("--> Packet sent OK"));
  }
  else 
  {
    USB.print(F("Error waiting for packets. error = "));  
    USB.println(error, DEC);   
  }
  
  delay(5000);
}

Radiomodulesetup is kept same as P2P send exmaple.

samimd19
Posts: 19
Joined: Wed Feb 21, 2018 10:14 am
Company: Saint Gobain Sekurit

Re: LoRAWAN and UART

Post by samimd19 » Thu May 17, 2018 4:57 pm

Hello,

The previous issue is solved but now I want to use a sleep command so that it wakes up every 2 minutes and send the UART values in a P2P commnication and then goes back to sleep again. As I am using the UART when the sleep command starts functioning it replies "Noise in Interruption Pin" and stops operating fully. How can this problem be solved?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: LoRAWAN and UART

Post by libelium-dev » Fri May 18, 2018 2:33 pm

Hi,

Interruptions are generated in UART1 pins, so if you connect an external device to UART1, it can cause noise and therefore sleep() functions doesn't work. Try to close uart before sleep() function

Code: Select all

	// close UART
	closeSerial(1);
Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest