Go Down

Topic: X Bee Series 1 RSSI signal pin values (Read 956 times) previous topic - next topic

Greetings! So I am currently sending the values from an X Bees RSSI pin to another X Bee and reading the incoming values, then printing on an LCD.

problem: The incoming values are only showing a range of 0-43ish. I want to see values extending to the 300ft range. I'm not sure what I am doing wrong. Here is my AT commands for each xbee, along with my sender and receiver code:

Receiver                            emitter(everything same as receiver except ones listed)
ATID4256
ATP01
ATIR0
ATCE0                              ATCE1
ATBD5
ATM02
ATRP10

Code: [Select]
// Emitter Code for xbee RSSI pin





const int rssi_pin = 9; //RSSI Pin of the XBee Module
int rssiDur; //variable to read pin
byte inches_val;

//LED pins//////////////////////////
const int led3 = 3;
const int led4 = 4;
const int led5 = 5;
const int led6 = 6;
const int led7= 7;
const int led8= 8;
const int led10= 10;
const int led11= 11;
const int led12= 12;
const int led13= 13;
/////////////////////////////////////

///Averager Variables///////////////////////////////

//this is intended to place first 10 read incoming RSSI values in an array and average. smoother readings

const int numReadings = 10;

int readings[numReadings];      // the readings from the RSSI
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average


///////////////////////////////////////////////////



void setup(){
 
   for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;

pinMode (led3, OUTPUT);
pinMode (led4, OUTPUT);
pinMode (led5, OUTPUT);
pinMode (led6, OUTPUT);
pinMode (led7, OUTPUT);
pinMode (led8, OUTPUT);
pinMode (led10, OUTPUT);
pinMode (led11, OUTPUT);
pinMode (led12, OUTPUT);
pinMode (led13, OUTPUT);
 
 
  Serial.begin(38400); //Xbee communicating at this baud
}

void loop(){


rssiDur = pulseIn(rssi_pin, LOW, 200); //this is set to 200ms with ATRP @ 2
inches_val = rssiDur ;
total= total - readings[index];         
  // read from the sensor: 
  readings[index] = inches_val;
  // add the reading to the total:
  total= total + readings[index];       
  // advance to the next position in the array: 
  index = index + 1;                   

  // if we're at the end of the array...
  if (index >= numReadings)             
    // ...wrap around to the beginning:
    index = 0;                           

  // calculate the average:
  average = total / numReadings;         
 

  Serial.write(average);   
  delay(100);        // delay in between rea


// value 10 = 1 meter
if (average > 18 && average < 196){ //1-5 meters
// Serial.write(1);
   digitalWrite(led3, HIGH);
       digitalWrite(led4, HIGH);
        digitalWrite(led5, HIGH);
        digitalWrite(led6, HIGH);
        digitalWrite(led7, HIGH);
        digitalWrite(led8, HIGH);
        digitalWrite(led10, HIGH);
        digitalWrite(led11, HIGH);
        digitalWrite(led12, HIGH);
        digitalWrite(led13, HIGH);
       
}
  if (average > 196 && average < 393){ //5-10 meters
  //Serial.write(2);
   digitalWrite(led3, HIGH);
       digitalWrite(led4, HIGH);
        digitalWrite(led5, HIGH);
        digitalWrite(led6, HIGH);
        digitalWrite(led7, HIGH);
         digitalWrite(led8, HIGH);
        digitalWrite(led10, HIGH);
        digitalWrite(led11, HIGH);
        digitalWrite(led12, LOW);
        digitalWrite(led13, LOW);
       
  }
  if (average > 393 && average < 590){ //10- 15 meters
  //Serial.write(3);
   digitalWrite(led3, HIGH);
       digitalWrite(led4, HIGH);
        digitalWrite(led5, HIGH);
        digitalWrite(led6, HIGH);
        digitalWrite(led7, HIGH);
         digitalWrite(led8, HIGH);
         digitalWrite(led10, LOW);
        digitalWrite(led11, LOW);
        digitalWrite(led12, LOW);
        digitalWrite(led13, LOW);
       
  }
  if (average > 590 && average < 787){ //15-20 meters
  //Serial.write(4);
    digitalWrite(led3, HIGH);
       digitalWrite(led4, HIGH);
        digitalWrite(led5, HIGH);
        digitalWrite(led6, HIGH);
        digitalWrite(led7, LOW);
           digitalWrite(led8, LOW);
        digitalWrite(led10, LOW);
        digitalWrite(led11, LOW);
        digitalWrite(led12, LOW);
        digitalWrite(led13, LOW);
       
  }
  if (average > 787 ){ //20-30 meters
// Serial.write(5);
   digitalWrite(led3, HIGH);
       digitalWrite(led4, HIGH);
        digitalWrite(led5, LOW);
        digitalWrite(led6, LOW);
        digitalWrite(led7, LOW);
         digitalWrite(led8, LOW);
        digitalWrite(led10, LOW);
        digitalWrite(led11, LOW);
        digitalWrite(led12, LOW);
        digitalWrite(led13, LOW);
     
    }
   
 
}



...and the receiver

Code: [Select]
#include <LiquidCrystal.h>

const int ledPin = 13;
//const int signalStrengthPin = 9;

byte incomingByte, val_read;




//int RSSIpin = 9;
//unsigned long rssiDur;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  Serial.begin(38400);
lcd.begin(16,2);
lcd.noAutoscroll();
  pinMode(ledPin, OUTPUT);
// pinMode(signalStrengthPin, INPUT);
}

void loop()
{


//rssiDur = pulseIn(RSSIpin, LOW, 200);
  // print signal strength
  //Serial.println(rssiDur);

  if (Serial.available()>0)
  {
   // incomingByte = Serial.read();
 
    //Serial.print(" Byte: ");
    //Serial.println(incomingByte);
        //delay(100);
       
       
  //while ((int(incomingByte) == 1)) {
   
val_read = Serial.read();
//Serial.print("Svalues =");
//int inches = val_read / mathbyte;
Serial.println(int(val_read));

delay(100);
//Serial.print(int(inches));
lcd.setCursor(0,0);
lcd.print("Bike1=");
lcd.print(int(val_read), DEC);

}



  }

PaulS

Quote
problem: The incoming values are only showing a range of 0-43ish. I want to see values extending to the 300ft range. I'm not sure what I am doing wrong.

Unrealistic expectations. The value returned by the RSSI pin is a relative signal strength. Relative to what? Damned good question.

Missed you PaulS!

yes, as stated in any forum, a measurement of signal strength is not the most accurate means to measure distance. ANYWAYS, in an ideal/interference free area, a measurement of the signal strength has been working for me until my issue (refer to the entire outlined explanation above)

KeithRB

If val_read is a byte, it is kind of hard to get values more than 255.

PaulS

#4
Nov 07, 2012, 10:39 pm Last Edit: Nov 07, 2012, 10:41 pm by PaulS Reason: 1
I don't understand what you are doing with the pulseIn() function on pin 9. How are you attaching the XBee to the Arduino?

According to digi.com, the RSSI value associated with the last packet is available by putting the XBee in command mode (send it +++), and then sending it the AT command DB (ATDB). The XBee then responds with the RSSI value.

The value returned is in -dB. There does not appear to be a good correlation between this value and distance. Certainly expecting a 300 foot distance to return a value of 300 is unrealistic.

Nevermind, I solved it. Since im reading from the RSSI pin, I adjusted an AT command to set the pwm duty cycle to 99.

Go Up