Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 7 months ago.
not getting rssi value from the xbee
hi guys ,
does anyone know how to get rssi value using mbed???
i used the program written here http://mbed.org/users/ATKINZ117/code/XBeeGetRSSISampleProgram/ but i m getting 0dBm as answer.. plz help asap
1 Answer
10 years, 7 months ago.
Does your xbee module need to receive data from anther radio before it will output a meaningful rssi? It's hard to give a signal strength number if you've not seen any signals.
yup it need to recv data from tx (mbed+xbee) the code which i am writing for tx is
#include "mbed.h" Serial pc(USBTX, USBRX); Serial xbee1(p9,p10); DigitalOut rst1(p8); //Digital reset for the XBee, 200ns for reset DigitalOut myled(LED3);//Create variable for Led 3 on the mbed int main() { rst1 = 0; //Set reset pin to 0 myled = 0;//Set LED3 to 0 wait_ms(1);//Wait at least one millisecond rst1 = 1;//Set reset pin to 1 wait_ms(1);//Wait another millisecond while (1) {//Neverending Loop myled = 1; int Y=8; xbee1.printf("%d", Y); //XBee write whatever the PC is sending wait(1); myled = 0; wait(1); } }
and at the receiving end the code is on the LINK
Can u help me with the code?? i m getting 0dBm as a answer... i think some modification is required at in the codes but i m not able to do it can anybody help me in it??
posted by 03 Apr 2014I don't have a xbee radio to try this with so this is partly guesswork and some pointers on coding to make things a little easier/cleaner. Also I've not tested the code below so there may be a few syntax errors etc...
First off make the XBeeGetRssi class inherit from Serial, in the header
class XBeeGetRssi : public Serial { ....
and then in the .cpp:
XBeeGetRssi::XBeeGetRssi(PinName tx,PinName rx) : Serial (tx,rx) { ... }
And then remove any other locations where you try to open the serial port to the radio, it's already done when you create the XBeeGetRssi object. Within XBeeGetRssi just call putc() / getc() (and any other Serial functions) without any prefix.
This then allows the parent (main in this case) to call the standard serial port functions on your port as well as call your RSSI function. In the main I would then wait until you have received a character until you try to get the RSSI
XBeeGetRssi RSSI(p9,p10); //tx,rx Serial pc(USBTX,USBRX); myled DigitalOut ( LED1 ); // set to correct LED pin int rssi; int main(){ myled = 0; char byteIn; while(1){ while (!RSSI.readable()) { myled = !myled; wait_ms(100); // loop until we get some data } byteIn = RSSI.getc(); rssi=RSSI.getRssi(); pc.printf("Got %c with RSSI:%ddBm\n",byteIn,rssi); } }
if in doubt set some code up to allow you to directly mirror the PC serial port to the module and the module serial port to the PC. That lets you can manually enter the commands and see what reply you are getting from the module.
Serial pc(USBTX,USBRX); Serial Xbee(tx,rx); // insert pin numbers here. void pcIn( if (pc.readable() && Xbee.writeable()) Xbee.putc(pc.getc()); ) void radioIn( if (XBee.readable() && pc.writeable()) pc.putc(XBee.getc()); ) main{ Xbee.attach(&radioIn); pc.attach(&pcIn); }
One afterthought. Do you need to set the baud rate to the radio? The mbed default is 9600, if you radio is something different you'd need to set that before trying to talk to it. e.g.
RSSI.baud(38400);
i wrote the code which u suggested for the rx but i m not getting anything as output but Led1 is glowing on n off.. ie it is still not receiving any thing... the tx program which i wrote was
the code which i am writing for tx is
include "mbed.h" Serial pc(USBTX, USBRX); Serial xbee1(p9,p10); DigitalOut rst1(p8); //Digital reset for the XBee, 200ns for reset DigitalOut myled(LED3);//Create variable for Led 3 on the mbed int main() { rst1 = 0; //Set reset pin to 0 myled = 0;//Set LED3 to 0 wait_ms(1);//Wait at least one millisecond rst1 = 1;//Set reset pin to 1 wait_ms(1);//Wait another millisecond char a; while (1) {//Neverending Loop myled = 1; //Turn Led 3 Off a='A'; xbee1.printf("%c", a); //XBee write whatever the PC is sending // xbee1.putc(Y); wait(1); myled = 0; //Turn Led 3 on for succcessfull communication wait(1); } }
can u plz check the see the TX program at once please ...is there any mistake i m doing??
posted by 05 Apr 2014Nothing obviously wrong that I can see. The default settings for serial ports should be correct assuming your XBee is still on it's default.
Time to double check your wiring, make sure power and ground are correct and your power supply can output enough power, reset goes to the correct place and that you have the serial port pins the correct way around etc... it could be a hardware issue.
posted by 07 Apr 2014