Home/Support/Support Forum/connecting a PIC to arduino with a 802 Xbee modules

connecting a PIC to arduino with a 802 Xbee modules

0 votes
Hi

I am looking to transmit data from various sensors which are being sent to dsPIC33EP64GS502. This data will then be sent into a Xbee 802.15.4 module. I am planning on the send the data using API. this will then be received by XBee 802.15.4 module and then go into an Arduino. I am using the Arduino to convert the data sent from the sensors to useful information because I find the Arduino coding simpler. Would this communication work with sending the data from a PIC to a Arduino?

is there any example codes of using a dspic33 with a Xbee 802.15.4 module?

thanks

Dave
asked Mar 26, 2016 in IEEE 802.15.4 by dave1993 New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
As long as the Pic has a UART, you should be able to get it to work. Just think of the radio's as nothing more than a cable on that com port between the two.

Why use API mode on your PIC? If you just set the DL and DH on the XBee, it will send the data to the matching XBee module with that address. This will reduce your code on your Pic and make it easier for you. Using API mode then on your Arduino will still allow you to know who the data came from and they will still talk back and forth.
answered Mar 28, 2016 by mvut Veteran of the Digi Community (12,302 points)
Thanks for the Answer!

I am Still waiting on getting my Xbee modules should be tomorrow and then I can begin testing it out.

I am configuring the code for my pic like so

//Radio Transmission

U1MODEbits.STSEL =0;// 1 stop section bit

U1MODEbits.BRGH=0; // set to 16 bit

U1BRG=0000000000000000; //U1BRG set to zero baud rate will be 230400

U1MODEbits.PDSEL0=1; // 9 bit no parity sent in parts (PDSEL0 and PDSEL1)

U1MODEbits.PDSEL1=1; //

U1MODEbits.UARTEN=1; // UART is enabled

U1STAbits.UTXEN=1; // Transmit Enable bit

U1TXREG= Temp; // Send Temp

//delay?

U1TXREG= Accel1XG; // send ACCEL1XG value

Basically it sets the Baud rate to 230400, then sets it to send the code in 9bits with no parity. I plan on programming each XBee module using a micro USB adapter to plug my Xbee's into my PC. Does this seem like it will work to you?

Thanks again

Dave
I would strongly suggest you read over the product manual for the XBee 802.15.4 modules before you go any farther.   You see the default baud rate for the product is 9600bps with a Streaming limit of 80kbps.  Setting your code for a rate that the radio does not support seems to be going in the wrong direction to me.
Sorry I am little confused on the data sheet it says the Baud rate is in-between 1200 b/s and 250 kb/s.  It has some standard baud rates up to 115200. Are these values not supported? I can see that as you get to higher values the UART speed is less accurate -3.5% for 115,200. I Ideally want the Baud rate to be as high as possible I can understand that would cause errors. with that in mind would it work for the 115, 200 value or would it be better to go with the 9600 Value.

Thanks again

Dave
Yes both standard and none standard Serial baud rate up to 250kbps are supported. But after overhead, the effective streaming limit of the radio is ~80kbps. So interfacing at rates above 115.2kbps really does nothing other than allow the data to flow to and from the radio and your processor at higher rates.  The amount of data that you can transmit remains at 80kbps total.
...