I have this little bit of code written for a copter telemetry system and find that it works really well, however, I did notice that the RSSI strength works very well with the 2.4ghz Xbee Pro radios and not well at all with the 900mhz Pro radios. The 2.4s range from 100% to about 20% before completely dropping out and gets weaker as I walk farther from the transmitting radio. The 900s tend to hang about 46% (with the antennas within inches of each other) instead of 100% and the signal does not show that it gets all that much weak as I walk away. I get about 700ft away and the signal will begin to flicker between 46-35% and then drops.
Does anyone know what the difference is between the two radios and the way that they transmit RSSI?
Thanks
Here is the code:
#include <TextFinder.h>
#include "PCD8544.h"
TextFinder finder(Serial);
const int NUMBER_OF_FIELDS = 24; // how many comma-separated fields we expect
int fieldIndex = 0; // the current field being received
float values[NUMBER_OF_FIELDS]; // array holding values for all the fields
//Adafruit Pin out. Sparkfun may be different
// pin 7 - (SCLK)
// pin 6 - (DIN)
// pin 5 - (D/C)
// pin 4 - (CS)
// pin 3 - (RST)
PCD8544 nokia = PCD8544(7, 6, 5, 4, 3);
float batPix = 0; //Pixel for battery graphics
int rssiPix = 0; //Pixel for battery graphics
float deltaV = 0; //Used for the battery graphic
int craftHeading = 0;
int craftAlt = 0;
float craftBattery = 0;
int rssiDur = 0;
int rssiPercent;
void setup()
{
Serial.begin(57600); // Initialize serial port to send and receive at 57600 baud
pinMode(19, INPUT); //Xbee RSSI pin
nokia.init();
nokia.setContrast(45);
}
void loop()
{
Serial.print('x');
Serial.print('s');
nokia.clear(); //clearing LCD
for(fieldIndex = 0; fieldIndex < 24; fieldIndex ++)
{
values[fieldIndex] = finder.getFloat(); // get a numeric value
}
Serial.print('x');
//Assigning craft values based on array index numbers
craftHeading = (values[3] * 57.17); //57.17 is to convert 0-6 to 0-359*
craftAlt = (values[4] * 3.28084); //3.28084 to convert to feet
craftBattery = values[22] + 0.28; //0.28 is a battery correction factor for the AQ32 wacky battery VD
rssiDur = pulseIn(19, HIGH, 100);
rssiPercent = 100 * rssiDur / 64;
if(rssiDur < 1){ // If the PWM = 100%, there is no duration (rssiDur = 0us)
rssiPercent = 100; // so we use an if statement to override the false 0% reading
}
fieldIndex = 0; // ready to start over
//Graphic Math
deltaV = craftBattery - 10.0;
batPix = constrain(deltaV*13.75, 0, 33);
rssiPix = map(rssiPercent, 0, 100, 0, 33);
//--------------------------------------
nokia.setCursor(4, 0);
nokia.print("HDG");
nokia.setCursor(34, 0);
nokia.print("ALT");
nokia.setCursor(63, 0);
nokia.print("MDE");
nokia.drawline(25, 0, 25, 48, BLACK);
nokia.drawline(58, 0, 58, 48, BLACK);
nokia.drawline(0, 17, 84, 17, BLACK);
nokia.drawline(0, 27, 84, 27, BLACK);
nokia.drawline(0, 37, 84, 37, BLACK);
nokia.setCursor(4, 9);
nokia.print(craftHeading);
nokia.setCursor(34, 9);
nokia.print(craftAlt);
nokia.setCursor(0, 19);
nokia.print("BATT");
nokia.setCursor(60, 19);
nokia.print(craftBattery);
nokia.setCursor(0, 29);
nokia.print("RSSI");
nokia.setCursor(60, 29);
nokia.print(rssiPercent);
//nokia.setCursor(0, 39);
//nokia.print("ATAL");
//nokia.setCursor(30, 39);
//nokia.print("BTAL");
//nokia.setCursor(60, 39);
//nokia.print("XTRA");
nokia.fillrect(25, 19, batPix, 7, 1);
nokia.fillrect(25, 29, rssiPix, 7, 1);
if(values[23]>=1.0){
nokia.setCursor(63, 9);
nokia.print("ATT");
}
else{
nokia.setCursor(63, 9);
nokia.print("RTE");
}
nokia.display();
}