Post a new topicPost a reply Page 1 of 1   [ 10 posts ]
Author Message
 Post subject: How to get RSSI Value
PostPosted: Fri Jan 06, 2012 10:59 am 

Joined: Mon Dec 12, 2011 1:20 pm
Posts: 27
Hi libelium-dev

I read the : waspmote-technical_guide_eng.pdf, in page 56, i see the RSSI that i want be to use to measure distance between two mote, so the question is:

1/ how can i measure RSSI?
2/It is between Mote and Gateway or between Mote to Mote ?

When i read p 57, they use:

Quote:
In Waspmote this value is obtained simply by executing the function:
{
xbee.getRSSI();
}


and i see also the example given : ------Waspmote XBee 802.15.4 Getting RSSI Example------


I know that i can get RSSI after receiving a packet, so i use this code between Mote and Gateway, but always it give me RSSI=0;

Please tell me what's wrong in my code and how can i do????
CODE:

Code:
packetXBee* paq_sent;
long previous=0;
uint8_t state=0;
uint8_t g=0;
char* data="Good Morning";
void setup()
{
  // Inits the XBee 802.15.4 library
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
 
  // Powers XBee
  xbee802.ON();
}

void loop()
{
  paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
  paq_sent->mode=BROADCAST;
  paq_sent->MY_known=0;
  paq_sent->packetID=0x52;
  paq_sent->opt=0;
  xbee802.hops=0;
  xbee802.setOriginParams(paq_sent,MAC_TYPE);
  xbee802.setDestinationParams(paq_sent, "0013A20040762047",data, MAC_TYPE, DATA_ABSOLUTE);
 sprintf(data,"-RSSI:%d",xbee802.getRSSI(),'\r','\n');
   xbee802.sendXBee(paq_sent);
   
  // Waiting message
  previous=millis();
  while( (millis()-previous) < 10000 )
  {
    if( XBee.available() )
    {
      xbee802.treatData();
      if( !xbee802.error_RX )
      {
        while(xbee802.pos>0)
        {       
          XBee.print("RSSI: ");                   
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->RSSI,HEX);
          free(xbee802.packet_finished[xbee802.pos-1]);
          xbee802.packet_finished[xbee802.pos-1]=NULL;
          xbee802.pos--;
        }
      }
    }
  }
 
  // Getting RSSI using the API function
  xbee802.getRSSI();
  if( !xbee802.error_AT ){
    XBee.print("RSSI: ");
    XBee.println(xbee802.valueRSSI[0],HEX);
  }
 
  free(paq_sent);
  paq_sent = NULL;
}



Please tell me how can i do, because i have a project to do it, it is to calculate the distance between 5 mote.

Thankyou...

Regard
ghorbel


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Mon Jan 09, 2012 11:15 am 

Joined: Sun Jan 08, 2012 7:32 pm
Posts: 26
Hi libelium-Dev

Please can you tell me How can I do to get RSSI value???

Can you answer my previous question please...

Regard
ghorbel


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Tue Jan 10, 2012 12:56 pm 

Joined: Mon Dec 12, 2011 1:20 pm
Posts: 27
Hi libelium-dev

Please can you answer my question in RSSI... because i'm stuck in this step.

Best Regard
Ghorbel


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Fri Jan 13, 2012 12:10 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Hi,

When you do this:
Code:
sprintf(data,"-RSSI:%d",xbee802.getRSSI(),'\r','\n');
You haven't send/received any packet yet. You should do it after receiving it.
What does your Waspmote print on your serial monitor when you do this:
Code:
XBee.print("RSSI: ");
XBee.print(xbee802.packet_finished[xbee802.pos-1]->RSSI,HEX);


Bes regards!


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Sat Jan 14, 2012 1:19 am 

Joined: Mon Dec 12, 2011 1:20 pm
Posts: 27
Hi libelium-dev
Thanks for the reply

i use another code to show data and the RSSI, but i obtain a strange value...

code:


packetXBee* paq_sent;
int8_t state=0;
long previous=0;
char* data = "Mote 1 sending";
int g=0;
uint8_t PANID[2]={0x12,0x34};

void setup()
{
// Inits the XBee 802.15.4 library
xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);

// Powers XBee
xbee802.ON();
}

void loop()
{
// Chosing a channel : channel 0x0D
xbee802.setChannel(0x0D);
if( !xbee802.error_AT ) XBee.println("Channel set OK");
else XBee.println("Error while changing channel");

// Chosing a PANID : PANID=0x1234
xbee802.setPAN(PANID);
if( !xbee802.error_AT ) XBee.println("PANID set OK");
else XBee.println("Error while changing PANID");

// Set params to send
paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
paq_sent->mode=BROADCAST;
paq_sent->MY_known=0;
paq_sent->packetID=0x52;
paq_sent->opt=0;
xbee802.hops=0;
// xbee802.setOriginParams(paq_sent, "0013A20040693723", MY_TYPE);
xbee802.setOriginParams(paq_sent, MY_TYPE);
xbee802.setDestinationParams(paq_sent, "0013A20040762047", data, MAC_TYPE, DATA_ABSOLUTE);
xbee802.sendXBee(paq_sent);
sprintf(data, "RSSI is : %x ","dBm\n",xbee802.getRSSI(),'\r','\n');
if( !xbee802.error_TX )
{
XBee.println("ok");
}
free(paq_sent);
paq_sent=NULL;

// Waiting the answer
previous=millis();
while( (millis()-previous) < 10000 )
{
if( XBee.available() )
{
xbee802.treatData();
if( !xbee802.error_RX )
{
// Writing the parameters of the packet received
while(xbee802.pos>0)
{
XBee.print("Network Address Source: ");
XBee.print(xbee802.packet_finished[xbee802.pos-1]->naS[0],HEX);
XBee.print(xbee802.packet_finished[xbee802.pos-1]->naS[1],HEX);
XBee.println("");
XBee.print("MAC Address Source: ");
for(int b=0;b<4;b++)
{
XBee.print(xbee802.packet_finished[xbee802.pos-1]->macSH[b],HEX);
}
for(int c=0;c<4;c++)
{
XBee.print(xbee802.packet_finished[xbee802.pos-1]->macSL[c],HEX);
}
XBee.println("");
XBee.print("Network Address Origin: ");
XBee.print(xbee802.packet_finished[xbee802.pos-1]->naO[0],HEX);
XBee.print(xbee802.packet_finished[xbee802.pos-1]->naO[1],HEX);
XBee.println("");
XBee.print("MAC Address Origin: ");
for(int d=0;d<4;d++)
{
XBee.print(xbee802.packet_finished[xbee802.pos-1]->macOH[d],HEX);
}
for(int e=0;e<4;e++)
{
XBee.print(xbee802.packet_finished[xbee802.pos-1]->macOL[e],HEX);
}
XBee.println("");
XBee.print("RSSI: ");
XBee.print(xbee802.packet_finished[xbee802.pos-1]->RSSI,HEX);
XBee.println("");
XBee.print("16B(0) or 64B(1): ");
XBee.print(xbee802.packet_finished[xbee802.pos-1]->mode,HEX);
XBee.println("");
XBee.print("Data: ");
for(int f=0;f<xbee802.packet_finished[xbee802.pos-1]->data_length;f++)
{
XBee.print(xbee802.packet_finished[xbee802.pos-1]->data[f],BYTE);
}
XBee.println("");
XBee.print("PacketID: ");
XBee.print(xbee802.packet_finished[xbee802.pos-1]->packetID,HEX);
XBee.println("");
XBee.print("Type Source ID: ");
XBee.print(xbee802.packet_finished[xbee802.pos-1]->typeSourceID,HEX);
XBee.println("");
XBee.print("Network Identifier Origin: ");
while( xbee802.packet_finished[xbee802.pos-1]->niO[g]!='#' )
{
XBee.print(xbee802.packet_finished[xbee802.pos-1]->niO[g],BYTE);
g++;
}
g=0;
XBee.println("");
free(xbee802.packet_finished[xbee802.pos-1]);
xbee802.packet_finished[xbee802.pos-1]=NULL;
xbee802.pos--;
}
previous=millis();
}
}
}

// Getting RSSI using the API function
xbee802.getRSSI();
if( !xbee802.error_AT ){
XBee.print("RSSI: ");
XBee.println(xbee802.valueRSSI[0],HEX);
}

delay(3000);
}

At the screen, i see this:
~ € }3¢ @o³cR# Mote 1 sending~ € }3¢ @o³c#R# RSSI is : 2740æ~ € }3¢ @o³c/R# RSSI is : 2740Ú~ € }3¢ @o³cAR# RSSI is : 2740È

Please what's the problem exactly????


Question: please i want to know when i want to use the RSSI, i use (1 mote+Gateway) or (2 mote+gateway)... or what can i use exactly???

have you an example that is work fine that i can use it ???

Best Regard
ghorbel


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Mon Jan 16, 2012 7:24 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Dear ghorbel,

Quote:
Please what's the problem exactly????

In your code, at line:
Code:
sprintf(data, "RSSI is : %x ","dBm\n",xbee802.getRSSI(),'\r','\n');

Your are printing RSSI as hexadecimal value. Change type choosing the best for you.

Quote:
Question: please i want to know when i want to use the RSSI, i use (1 mote+Gateway) or (2 mote+gateway)... or what can i use exactly???

Getting the RSSI value is not mandatory. you can use it or not. Regarding your network topology, you can use all that you mention.
Quote:
have you an example that is work fine that i can use it ???

There is an example included in Waspmote IDE called Getting_RSSI. Try this example to see how it works.

Kind Regards.


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Sun Jan 22, 2012 12:09 pm 

Joined: Mon Dec 12, 2011 1:20 pm
Posts: 27
Hi libelium -dev

Thank you for the reply...

When i use this code, i see the HEX value at the screen (the receive mote attached to the USB port) and it's ok.
XBee.print("RSSI: ");
XBee.print(xbee802.packet_finished[xbee802.pos-1]->RSSI,HEX);

But now , when i want to see the RSSI at the screen using the GateWay (Radio 802.15.4) i can't see the value... please can you tell me How can i do to resolve my problem???

Can use this:
Sprintf(data,"RSSI: ",xbee802.packet_finished[xbee802.pos-1]->RSSI,HEX); ???? to show RSSI in radio using gateway?

Best Regard
Ghorbel


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Mon Jan 23, 2012 9:39 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
ghorbel,

If you want to see the RSSi value on your gateway, first you have to send it to the gateway xbee.

As you say, you can use sprintf function to build data frame with RSSI value and later send it.

If you want to know further of the sprintf function please take a look into c++ reference here

Regards!


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Mon Jan 23, 2012 11:15 am 

Joined: Mon Dec 12, 2011 1:20 pm
Posts: 27
Hi libelium-dev
Thanks for the reply...
I got it and it's work well with Hex value... and it should be converted to the decimal.

Now i want to know can i transform this value to percent ( e.g: 88%) and print it in the screen...
there is any formula or what can i do??

Kind Regard
ghorbel


Top
 Profile  
 
 Post subject: Re: How to get RSSI Value
PostPosted: Mon Jan 23, 2012 3:24 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Dear ghorbel,

In this topic this issue is mentioned.

We recommend you to read Digi documentation for your xbee module and calculate your own formula to display this data in %.

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