Important update: Arm Announces End of Life Timeline for Mbed. This site will be archived in July 2026. Read the full announcement.
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.
How send frame xbee using mbed
Topic last updated 11 May 2014, by
ilton oliveira.
1 reply

Hi guys, I need help, how do I send two frames to xbee S1 using mbed code , they turn on and off one relay
I use the devices: xbee base API = (SH = 0013A200) (SL = 40A040AC),
remote AT= (SH 0013A200) (SL = 40A13AB6)
Frame1: 7E 00 10 17 05 00 13 A2 00 40 A1 3A B6 FF FE 02 44 34 05 E1 ( turn on relay)
Frame2: 7E 00 10 17 05 00 13 A2 00 40 A1 3A B6 FF FE 02 44 34 04 E2 ( turn off relay)
I tested this frames in xbee board with X-CTU and everything worked
Tanks .
I GOT TO WORK WITH THE CODE BELOW :
include the mbed library with this snippet
#include "mbed.h" Serial xbee1(p13,p14); DigitalOut rst1(p11); //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; //Turn Led 3 Off //FRAME XBEE 1 xbee1.putc(0x7E); //start byte of API frame xbee1.putc(0x00); //high part of length.It always zero xbee1.putc(0x10); //low part of length.The number of bytes that follow,not including checksum xbee1.putc(0x17); // frame type.In this case 0x17 is a remote AT command xbee1.putc(0x05); //Frame ID.No acknowledgment is needed.The remote xbee will receive what we send xbee1.putc(0x00); xbee1.putc(0x13); //XBEE ANDRESS xbee1.putc(0xA2); //XBEE ANDRESS xbee1.putc(0x00);//XBEE ANDRESS xbee1.putc(0x40);//XBEE ANDRESS xbee1.putc(0xA1); ///XBEE ANDRESS xbee1.putc(0x3A); //XBEE ANDRESS xbee1.putc(0xB6); //XBEE ANDRESS xbee1.putc(0xFF); xbee1.putc(0xFE); xbee1.putc(0x02); xbee1.putc(0x44); // command name in ASCII characters "D" xbee1.putc(0x34); // command name in ASCII characters "4" xbee1.putc(0x05); // D 4 HIGH xbee1.putc(0xE1); //CHECKSUM wait(1); myled = 0; //Turn Led 3 on for succcessfull communication wait(1); xbee1.putc(0x7E); //start byte of API frame xbee1.putc(0x00); //high part of length.It always zero xbee1.putc(0x10); //low part of length.The number of bytes that follow,not including checksum xbee1.putc(0x17); // frame type.In this case 0x17 is a remote AT command xbee1.putc(0x05); //Frame ID.No acknowledgment is needed.The remote xbee will receive what we send xbee1.putc(0x00); xbee1.putc(0x13); //XBEE ANDRESS xbee1.putc(0xA2); //XBEE ANDRESS xbee1.putc(0x00);//XBEE ANDRESS xbee1.putc(0x40);//XBEE ANDRESS xbee1.putc(0xA1); //XBEE ANDRESS xbee1.putc(0x3A); //XBEE ANDRESS xbee1.putc(0xB6); //XBEE ANDRESS xbee1.putc(0xFF); xbee1.putc(0xFE); xbee1.putc(0x02); xbee1.putc(0x44); // command name in ASCII characters "D" xbee1.putc(0x34);// command name in ASCII characters "4" xbee1.putc(0x04);// D 4 LOW xbee1.putc(0xE2);//CHECKSUM wait(1); // FRAME XBEE2 xbee1.putc(0x7E); //start byte of API frame xbee1.putc(0x00); //high part of length.It always zero xbee1.putc(0x10); //low part of length.The number of bytes that follow,not including checksum xbee1.putc(0x17); // frame type.In this case 0x17 is a remote AT command xbee1.putc(0x05); //Frame ID.No acknowledgment is needed.The remote xbee will receive what we send xbee1.putc(0x00); xbee1.putc(0x13); xbee1.putc(0xA2); xbee1.putc(0x00); xbee1.putc(0x40); xbee1.putc(0xA0); xbee1.putc(0x40); xbee1.putc(0x37); xbee1.putc(0xFF); xbee1.putc(0xFE); xbee1.putc(0x02); xbee1.putc(0x44); xbee1.putc(0x34); xbee1.putc(0x05); xbee1.putc(0x5B); wait(1); xbee1.putc(0x7E); //start byte of API frame xbee1.putc(0x00); //high part of length.It always zero xbee1.putc(0x10); //low part of length.The number of bytes that follow,not including checksum xbee1.putc(0x17); // frame type.In this case 0x17 is a remote AT command xbee1.putc(0x05); //Frame ID.No acknowledgment is needed.The remote xbee will receive what we send xbee1.putc(0x00); xbee1.putc(0x13); xbee1.putc(0xA2); xbee1.putc(0x00); xbee1.putc(0x40); xbee1.putc(0xA0); xbee1.putc(0x40); xbee1.putc(0x37); xbee1.putc(0xFF); xbee1.putc(0xFE); xbee1.putc(0x02); xbee1.putc(0x44); xbee1.putc(0x34); xbee1.putc(0x04); xbee1.putc(0x5C); wait(1); } }
I GOT TO WORK WITH THE CODE BELOW :
<<code title=include the mbed library with this snippet>>
#include "mbed.h"
Serial xbee1(p13,p14);
DigitalOut rst1(p11); //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; //Turn Led 3 Off
//FRAME XBEE 1
xbee1.putc(0x7E); //start byte of API frame
xbee1.putc(0x00); //high part of length.It always zero
xbee1.putc(0x10); //low part of length.The number of bytes that follow,not including checksum
xbee1.putc(0x17); // frame type.In this case 0x17 is a remote AT command
xbee1.putc(0x05); //Frame ID.No acknowledgment is needed.The remote xbee will receive what we send
xbee1.putc(0x00);
xbee1.putc(0x13); //XBEE ANDRESS
xbee1.putc(0xA2); //XBEE ANDRESS
xbee1.putc(0x00);//XBEE ANDRESS
xbee1.putc(0x40);//XBEE ANDRESS
xbee1.putc(0xA1); ///XBEE ANDRESS
xbee1.putc(0x3A); //XBEE ANDRESS
xbee1.putc(0xB6); //XBEE ANDRESS
xbee1.putc(0xFF);
xbee1.putc(0xFE);
xbee1.putc(0x02);
xbee1.putc(0x44); // command name in ASCII characters "D"
xbee1.putc(0x34); // command name in ASCII characters "4"
xbee1.putc(0x05); // D 4 HIGH
xbee1.putc(0xE1); //CHECKSUM
wait(1);
myled = 0; //Turn Led 3 on for succcessfull communication
wait(1);
xbee1.putc(0x7E); //start byte of API frame
xbee1.putc(0x00); //high part of length.It always zero
xbee1.putc(0x10); //low part of length.The number of bytes that follow,not including checksum
xbee1.putc(0x17); // frame type.In this case 0x17 is a remote AT command
xbee1.putc(0x05); //Frame ID.No acknowledgment is needed.The remote xbee will receive what we send
xbee1.putc(0x00);
xbee1.putc(0x13); //XBEE ANDRESS
xbee1.putc(0xA2); //XBEE ANDRESS
xbee1.putc(0x00);//XBEE ANDRESS
xbee1.putc(0x40);//XBEE ANDRESS
xbee1.putc(0xA1); //XBEE ANDRESS
xbee1.putc(0x3A); //XBEE ANDRESS
xbee1.putc(0xB6); //XBEE ANDRESS
xbee1.putc(0xFF);
xbee1.putc(0xFE);
xbee1.putc(0x02);
xbee1.putc(0x44); // command name in ASCII characters "D"
xbee1.putc(0x34);// command name in ASCII characters "4"
xbee1.putc(0x04);// D 4 LOW
xbee1.putc(0xE2);//CHECKSUM
wait(1);
// FRAME XBEE2
xbee1.putc(0x7E); //start byte of API frame
xbee1.putc(0x00); //high part of length.It always zero
xbee1.putc(0x10); //low part of length.The number of bytes that follow,not including checksum
xbee1.putc(0x17); // frame type.In this case 0x17 is a remote AT command
xbee1.putc(0x05); //Frame ID.No acknowledgment is needed.The remote xbee will receive what we send
xbee1.putc(0x00);
xbee1.putc(0x13);
xbee1.putc(0xA2);
xbee1.putc(0x00);
xbee1.putc(0x40);
xbee1.putc(0xA0);
xbee1.putc(0x40);
xbee1.putc(0x37);
xbee1.putc(0xFF);
xbee1.putc(0xFE);
xbee1.putc(0x02);
xbee1.putc(0x44);
xbee1.putc(0x34);
xbee1.putc(0x05);
xbee1.putc(0x5B);
wait(1);
xbee1.putc(0x7E); //start byte of API frame
xbee1.putc(0x00); //high part of length.It always zero
xbee1.putc(0x10); //low part of length.The number of bytes that follow,not including checksum
xbee1.putc(0x17); // frame type.In this case 0x17 is a remote AT command
xbee1.putc(0x05); //Frame ID.No acknowledgment is needed.The remote xbee will receive what we send
xbee1.putc(0x00);
xbee1.putc(0x13);
xbee1.putc(0xA2);
xbee1.putc(0x00);
xbee1.putc(0x40);
xbee1.putc(0xA0);
xbee1.putc(0x40);
xbee1.putc(0x37);
xbee1.putc(0xFF);
xbee1.putc(0xFE);
xbee1.putc(0x02);
xbee1.putc(0x44);
xbee1.putc(0x34);
xbee1.putc(0x04);
xbee1.putc(0x5C);
wait(1);
}
}
<</code>>
Hi guys, I need help, how do I send two frames to xbee S1 using mbed code , they turn on and off one relay
I use the devices: xbee base API = (SH = 0013A200) (SL = 40A040AC), remote AT= (SH 0013A200) (SL = 40A13AB6)
Frame1: 7E 00 10 17 05 00 13 A2 00 40 A1 3A B6 FF FE 02 44 34 05 E1 ( turn on relay)
Frame2: 7E 00 10 17 05 00 13 A2 00 40 A1 3A B6 FF FE 02 44 34 04 E2 ( turn off relay)
I tested this frames in xbee board with X-CTU and everything worked
Tanks .