For my project, I would like to have a rudimentary distance measuring tool between two Arduino with Xbee Shields. I don't need anything fancy, just an indication of 'far(rish)', 'close(ish)' and 'right next to each other'. Since I'm on budget and time contraints, buying extra sensors (like sonic radars and whatnot) isn't really feasible. So I would have to use the signal of the Xbee shield for this.
After looking around on the net, I found this paper: Precise distance measurement with IEEE 802.15.4 (ZigBee) devices (apologies to those who can't open it).
It looks promising, but I get stuck on the fact that I have to take the map the phase difference and the time of arrival of the different signals between the shields on all 16 Zigbee channels and perform all kinds of complicated formulas on the measurements.
I have no idea how to read the phase difference between signals and am also not quite sure how what they mean by this (signal processing isn't my strong suit).
Another option might be to read out the last recorded signal strength between the Xbee shields. I should be able to do this by reading out pin 6 on the shield through an analog input. This is probably easier, but very inaccurate.
Any thoughts on the above? And if someone knows of an implementation of distance measuring with Xbees that they can share, I would be very grateful
Right now I connected pin 6 of the Xbee to an analog input and am reading that out each time I receive a new signal.
Now I keep getting values that are around 700 or 0, with the Zigbee close to each other. When I'm further off (even only in the next room), the Zigbee gets difficulty receiving signals, and mostly displays the values around 0. Especially the 0 is strange, since getting a signal with no strength seems odd. But I also find it strange that the seems to be getting 0 just as much as values around 700.
Does anyone know what the normal output range is for the RSSI pin? I can't seem to find that in the documentation. And a suggestion as what to do about that 0 signal strength?
/*
XBee_Receive_Example3_modifiedRSSI
An example of using the Arduino board to receive data from the
computer. In this case, the Arduino boards turns on an LED when
it receives the character 'H', and turns off the LED when it
receives the character 'L'.
The data can be sent from the Arduino serial monitor, or another
program like Processing (see code below), Flash (via a serial-net
proxy), PD, or Max/MSP.
The circuit:
* LED connected from digital pin 13 to ground
created 2006
by David A. Mellis
modified 14 Apr 2009
by Tom Igoe and Scott Fitzgerald
modified 2009
by Marta86
http://www.arduino.cc/en/Tutorial/PhysicalPixel
*/
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
#define analogPin 3
int RSSI=0; // holds the Received Signal Strength Value
int address=0; // holds the 16-bit address of the sender
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(analogPin, INPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
address = Serial.read(); // the sixth byte is the low part of the address
RSSI = Serial.read(); // the seventh byte is the RSSI value
analogWrite(10,(100-RSSI)*2); // analog write a brightness roughly corresponding to distance
}
Could you please post your code? It would help me a lot!