Pages: [1]   Go Down
Author Topic: XBee RSSI Value  (Read 6734 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know this has been posted a lot, but I cannot, for the life of me, get this RSSI value to work.  I have tried many different settings on my XBees, but right now I have P0 set to 1 (RSSI PMW0 Output) and M0 set to 10 (PWM0 duty cycle).  I have an Arduino Uno with a Libelium shield on a loop to output alphabet characters, and then I have an Arduino MEGA connected to an XBee, with the following code.

Code:
const int ledPin = 13;
const int signalStrengthPin = 7;

char incomingByte, checkByte;
unsigned long rssiDur;

void setup()
{
  Serial.begin(4800);
  Serial2.begin(9600);
 
  pinMode(ledPin, OUTPUT);
  pinMode(signalStrengthPin, INPUT);
}

void loop()
{
  if (Serial2.available() > 0)
  {
    incomingByte = Serial2.read();
    rssiDur = pulseIn(signalStrengthPin, LOW);
  }
 
  if (incomingByte != checkByte)
  {
    Serial.print(" Byte: ");
    Serial.print(incomingByte);
    Serial.print(" Strength: ");
    Serial.print(rssiDur);
    Serial.println();
    digitalWrite(ledPin, HIGH);
    checkByte = incomingByte;
    delay(200);
  }
  digitalWrite(ledPin, LOW);
}

The output I keep getting is "Byte:  a, b, c, etc. Strength: 24" no matter where I move the transmitting XBee to.  Does anyone have any advice?  I also looked at the output of Pin 6 on an oscilloscope, and it never changed as well...

Thanks.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Solution:
I made the following changes to the receiving XBee, or the XBee that will be reporting the RSSI value:
- Set M0 to 10
- Set CE to 2 (End device)
- Set PR to 3B7F (Disabled the RSSI pull-up resistor, kept all other pull-up resistor defaults)

and the following changes to the transmitting XBee:
- Set CE to 1 (Coordinator)

What I found is that when the XBees were close to one another, the RSSI value reported was 24, and about twenty yards away, through three walls, the RSSI value jumped between 34 and 38, sometimes not reporting values at all.  This makes sense because M0 is hexadecimal, so the maximum duration of the RSSI value would be decimal 16, or 40.  This assumes that the RSSI value would be greater at less signal strength.  Does anyone have any documentation to support this?  I couldn't find any.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3965
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You are trying to measure the RSSI pulse width?  Not sure if you can use this, as it may be a completely different approach.  Assumes: (1) A current XBee ZB module, e.g. XB24-Z7WIT-004, (2) XBee in API (AP=2) mode, (3) Andrew Rapp's XBee library.

With this I see values around -30dBm when the modules are close (same room, maybe even only inches apart), and -80 to -90dBm if they're several rooms apart, on different levels, etc.  Here is my Pachube feed which shows RSSI values from this function.

Code:
byte rss() {
    /* returns received signal strength value for the last RF data packet */

    union {byte B; char C;} atCmd[3];
    AtCommandRequest atCmdReq;
    AtCommandResponse atResp;
    byte respLen, *resp, dBm;

    strcpy(&atCmd[0].C, "DB");
    atCmdReq = AtCommandRequest(&atCmd[0].B);
    atResp = AtCommandResponse();

    xbee.send(atCmdReq);
    if (xbee.readPacket(5000)) {
        if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {
            xbee.getResponse().getAtCommandResponse(atResp);
            if (atResp.isOk()) {
                respLen = atResp.getValueLength();
                if (respLen == 1) {
                    resp = atResp.getValue();
                    dBm = resp[0];
                    return dBm;
                }
                else {
                    Serial.println("Unexpected response");
                }
            }
            else {
                Serial.println("ERROR");
            }
        }
        else {
            Serial.println("Unknown response");
        }
    }
    else {
        Serial.println("No response");
    }
}

From the XBee doc:

Quote
DB Command: Received Signal Strength. This command reports the received signal strength of the
last received RF data packet. The DB command only indicates the signal strength of the
last hop. It does not provide an accurate quality measurement for a multihop link. DB can
be set to 0 to clear it. The DB command value is measured in -dBm. For example if DB
returns 0x50, then the RSSI of the last packet received was
-80dBm. As of 2x6x firmware, the DB command value is also updated when an APS
acknowledgment is received.

Observed range for
XBee-PRO:
0x1A - 0x58
For XBee:
0x 1A - 0x5C
« Last Edit: May 04, 2011, 06:20:22 am by Jack Christensen » Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I am measuring the RSSI pulse width.  I considered using API mode, but for my project I needed to keep it in transparent mode.

Another solution would've been to enter command mode (sending "+++" serially to the XBee) and then to pull the information off, but this has a minimum two second wait time.  I couldn't afford such times because transmission data could potentially be lost.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3965
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I considered using API mode, but for my project I needed to keep it in transparent mode.

Why is that?  Just curious.

And, how critical is the RSSI information?  I only implemented it out of curiosity, have not really used the info for anything.  I actually haven't had any issues related to signal strength, indeed, the network seems quite robust.
« Last Edit: May 04, 2011, 07:08:37 am by Jack Christensen » Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know this has been posted a lot, but I cannot, for the life of me, get this RSSI value to work.  I have tried many different settings on my XBees, but right now I have P0 set to 1 (RSSI PMW0 Output) and M0 set to 10 (PWM0 duty cycle).  I have an Arduino Uno with a Libelium shield on a loop to output alphabet characters, and then I have an Arduino MEGA connected to an XBee, with the following code.

Code:
const int ledPin = 13;
const int signalStrengthPin = 7;

char incomingByte, checkByte;
unsigned long rssiDur;

void setup()
{
  Serial.begin(4800);
  Serial2.begin(9600);
  
  pinMode(ledPin, OUTPUT);
  pinMode(signalStrengthPin, INPUT);
}

void loop()
{
  if (Serial2.available() > 0)
  {
    incomingByte = Serial2.read();
    rssiDur = pulseIn(signalStrengthPin, LOW);
  }
  
  if (incomingByte != checkByte)
  {
    Serial.print(" Byte: ");
    Serial.print(incomingByte);
    Serial.print(" Strength: ");
    Serial.print(rssiDur);
    Serial.println();
    digitalWrite(ledPin, HIGH);
    checkByte = incomingByte;
    delay(200);
  }
  digitalWrite(ledPin, LOW);
}

The output I keep getting is "Byte:  a, b, c, etc. Strength: 24" no matter where I move the transmitting XBee to.  Does anyone have any advice?  I also looked at the output of Pin 6 on an oscilloscope, and it never changed as well...

Thanks.



What about using this code
Code:
rssiDur = pulseIn(signalStrengthPin, LOW, 200);

set P0 duty cycle at 99
Logged

Munich/Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

the xbee data sheet states that the PWM pulses vary from 24 to 100%. Zero percent
means PWM output is inactive. One to 24% percent means the received RF signal is at
or below the published sensitivity level of the module. The total period of the PWM
output is 64 μs. The PWM percentage can be calculated by high period / total period.
The following gives levels  above sensitivity and PWM values:

10 db is  41 %, 20 db is 58 and 30 db makes 75 %.

I implemented this like this:

 unsigned long rssiDur;
 float percentage;
 rssiDur = pulseIn(6, HIGH, 200);
 percentage=100 * rssiDur / 64;
 Serial.print("PWM raw signal:   ");
 Serial.println(rssiDur);
 Serial.print("PWM Percentage:   ");
 Serial.println(percentage);

Any comments?
Logged

Pages: [1]   Go Up
Jump to: