Hi, I am starting a project in witch I need to read the Xbee pro S2 packet using an arduino uno. I am trying to write a code to do it, but no success until now. If anyone have a clue on how to do it or have done something like this, please, help me! Thanks for your attention.
If anyone have a clue on how to do it
I have more than a clue. Use Serial or SoftwareSerial, depending on which pins the XBee is connected to.
What mode are the XBees in (AT or API)? How ARE the XBees configured?
Have you got a copy of Rod Faludi's book Building Wireless Sensor Networks? If not, you should.
PaulS:
I have more than a clue. Use Serial or SoftwareSerial, depending on which pins the XBee is connected to.What mode are the XBees in (AT or API)? How ARE the XBees configured?
Have you got a copy of Rod Faludi's book Building Wireless Sensor Networks? If not, you should.
hi,
thanks for the book indication, I am reading it and it has been very helpfull...
I am trying to work in API mode, however I have a question:
In my project, I intend to get the RSSI value from the END DEVICE and the ROUTER and send it to the COORDINATOR. Is it possible ?
Thanks for your help.
There is a small post I wrote some time ago, have a look, might be helpful Communication between Raspberry Pi and Arduino using XBee | Sony Arouje
it uses SoftwareSerial.
In my project, I intend to get the RSSI value from the END DEVICE and the ROUTER and send it to the COORDINATOR. Is it possible ?
It is possible. It is almost certainly meaningless. Why do you want to do that? RSSI is NOT even close to a good indicator of distance.
PaulS:
It is possible. It is almost certainly meaningless. Why do you want to do that? RSSI is NOT even close to a good indicator of distance.
Hi, I do not intend to use it as a indicator of distance. It is a university project to detect objects between the nodes. when there is a object in the line of sight, the rssi value decreases.
when there is a object in the line of sight, the rssi value decreases.
Not necessarily. Even if there IS a reduction, you have to know what the line of site value is at a given antenna orientation at a given power level, so that you can detect a decrease. This means, of course, that you know that the power level hasn't changed and that the antenna orientation has not changed, on either end.
How will you control those factors?
PaulS:
Not necessarily. Even if there IS a reduction, you have to know what the line of site value is at a given antenna orientation at a given power level, so that you can detect a decrease. This means, of course, that you know that the power level hasn't changed and that the antenna orientation has not changed, on either end.How will you control those factors?
I do not need accuracy in my project. I made some tests using XCTU range test and the rssi value changes when there is a obstacle (in a certain distance) in the line of sight of the antenna.
How I intend to control those factors ?
I intend to use just one type of antenna and place them in the same position in all nodes. After being able to get the rssi from the END DEVICE to the ROUTER and from the ROUTER to the COORDINATOR, I intend to monitor the RSSI value in order to identify if there is or there is not a obstacle and if it is between END DEVIDE and ROUTER or between ROUTER and COORDINATOR.
The xbees nodes are going to be placed at the same distance, and I am going to compare the decrease in the rssi value based on the initials values of rssi.
I have some questions:
- The power level changes automatically ?
- Is it possible to read the rssi value like I described, sending comands from the coordinator ?
Thanks for your attention and patience.
- The power level changes automatically ?
If the devices are battery powered, yes. A battery will not last forever.
- Is it possible to read the rssi value
It seems to me like you answered your own question:
I made some tests using XCTU range test and the rssi value changes
So, somehow you are seeing an RSSI value, somewhere. Where and how is not obvious to anyone that can't see over your shoulder. That would include most of us.
sending comands from the coordinator ?
Is there an Arduino at each node? If there is, then the coordinator can send a message that the Arduino understands, and the Arduino can query the XBee for the RSSI value, and return that to the coordinator.
Firstly, I am using an arduino connected to the router (using hardware serial) and another xbee conected to the computer via USB Adapter. I uploaded the following code (that was posted here in another topic), then I use XCTU to send packets using the console mode, but I obtain nothing in my Serial. Both Xbees are configured in API mode (1 coordinator and 1 router). Do you have any idea of what might be wrong ?
#include <XBee.h> //GitHub - andrewrapp/xbee-arduino: Arduino library for communicating with XBee radios in API mode
#include <Streaming.h> //http://arduiniana.org/libraries/streaming/
//XBee variables
XBee xbee = XBee(); //XBee object
ZBRxResponse rx = ZBRxResponse(); //XBee receive response
void setup(void)
{
Serial.begin(9600);
}
void loop(void)
{
xbee.readPacket();
if (xbee.getResponse().isAvailable()) {
switch (xbee.getResponse().getApiId()) { //what kind of packet did we get?
case ZB_RX_RESPONSE: //rx data packet
xbee.getResponse().getZBRxResponse(rx); //get the received data
switch (rx.getOption()) {
case ZB_PACKET_ACKNOWLEDGED:
Serial << "Packet received, RSS = -" << _DEC(rss()) << " DB" << endl;
break;
}
}
}
}
/-----------------------------------------------------------------------
- returns received signal strength value for the last RF data packet. *
-----------------------------------------------------------------------/
uint8_t rss() {
uint8_t atCmd[] = {'D', 'B'}, respLen, *resp, dBm;
AtCommandRequest atCmdReq;
AtCommandResponse atResp;
atCmdReq = AtCommandRequest(atCmd);
xbee.send(atCmdReq);
if (xbee.readPacket(10)) {
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 << "RSS LEN ERR" << endl; //unexpected length
}
}
else {
Serial << "RSS ERR" << endl; //status not ok
}
}
else {
Serial << "RSS UNEXP RESP" << endl; //expecting AT_COMMAND_RESPONSE, got something else
}
}
else {
Serial << "RSS NO RESP" << endl; //timed out
}
}
I apologize if my doubt is not totally clear, I am new to this technology and English is my second language. I appreciate your patience and comprehension.
Thanks for your help.
You make a lot of assumptions that are not necessarily true. Add more Serial.print() statements, to determine which of your assumptions are true, and which are false.
If you don't receive a packet, you don't print anything. So, you don't know whether or not you receive a packet.
If you do, you don't know what kind it is.
Add more Serial.print() statements to find out what is happening.