/* XBEE RSSI Reader a simple example of reading the address and RSSI information when receiving an I/O packet CAUTION: assumes a single digital sample only CAUTION: assumes a sender address between 0 and FF only by Rob Faludi www.faludi.com VERSION "1.00" */ int RSSI=0; // holds the Received Signal Strength Value int address=0; // holds the 16-bit address of the sender void setup() { Serial.begin(9600); } void loop () { if (Serial.available() > 13) { // if we have received at least one frome worth of bytes int inByte = Serial.read(); // read in a byte if (inByte == 0x7E) { // if it is the start byte for (int i=0;i<4;i++) { int junk = Serial.read(); // read and discard the next four bytes because we are not using them here } address = Serial.read(); // the sixth byte is the low part of the address RSSI = Serial.read(); // the seventh byte is the RSSI value for (int i=0;i<6;i++) { int junk = Serial.read(); // read and discard the following six bytes because we are not using them } } } /////////// SIMPLE USE OF THE INCOMING VALUE //////////////// if (address == 1) { analogWrite(10,(100-RSSI)*2); // analog write a brightness roughly corresponding to distance } else if (address == 2){ analogWrite(11,(100-RSSI)*2); // analog write a brightness roughly corresponding to distance } }