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, 10 months ago.
How to wire up MBED with two xbees
Hello,
I am trying to run the following program so that I can serially send a number from my PC to one xbee chip and receive it on another xbee and add 1 to it. I am having difficulty with how to wire the MBED chip and xbee chips.
// basic xbee example
// - take chars from the terminal, push them out xbee1
// - listen on xbee2, and print value + 1 to terminal
#include "mbed.h"
Serial xbee1(p9, p10);
DigitalOut rst1(p11);
Serial xbee2(p13, p14);
DigitalOut rst2(p15);
Serial pc(USBTX, USBRX);
int main() {
// reset the xbees (at least 200ns)
rst1 = 0;
rst2 = 0;
wait_ms(1);
rst1 = 1;
rst2 = 1;
wait_ms(1);
while(1) {
if(pc.readable()) {
xbee1.putc(pc.getc());
}
if(xbee2.readable()) {
pc.putc(xbee2.getc() + 1);
}
}
}
My questions are: 1) Since the MBED chip is being powered serially I do not need to power the chip using an external power supply? 2) Is it possible to power the xbee chips using the MBED microcontroller or do I need to use an external power supply.
I am completely new to this environment so any help would be appreciated.
MBED link: http://developer.mbed.org/users/vcazan/notebook/mbed--xbee/
Thanks, Astryl
2 Answers
10 years, 10 months ago.
Power does depend on the exact mbed board you are using. Most can be powered from USB but not all. Going by the serial port pins you are using I'm guessing you have an LPC1768. http://developer.mbed.org/platforms/mbed-LPC1768/
For that board you can certainly power the mbed from the USB connection.
For powering the xbee radios pin 40 (VOUT) will give you a 3.3V output that should be good for up to about 800mA although things will be getting very warm at that point.
Pin 39 (VU) is the USB input voltage. You can power any 5V external devices from that pin as long as they don't pull too much power.
Also when posting code here please put <<code>> in front of it and <</code>> after it (they have to be on their own lines) and the system will format it to be a lot more readable.
Yes, I am using LPC1768. I have also updated my comment with the <<code>> blocks. Thank you for the advice.
So I must connect the 'VCC' pins on both XBees to pin 40 (VOUT) of the LPC1768. How do I set up the ground connections? Do I just connect the GND pins on the XBees to the GND pin on the LPC1768?
Thanks
posted by 15 Jan 201510 years, 10 months ago.
To use the Xbee, you will need connect each Xbee as follows:
Mbed Tx to Xbee Rx (pin 3 Uart Data In)
Mbed Rx to Xbee Tx (pin2 Uart Data Out)
Mbed 3.3v to Xbee (pin 1 VCC)
Mbed ground (0v) to Xbee (pin 10 GND)
If you have the sleep enabled on the Xbee you will need this as well:
Mbed, any digital out pin to Xbee(pin 9 Pin Sleep Control) and set this low '0' to enable the Xbee, or set it high '1' to put the Xbee into low power sleep mode.
Something like this:
Xbee set up
// using Freescale pins Serial xbee(PTA2,PTA1); // tx, Rx DigitalOut xbeeWake(PTD4); // Xbee sleep control
You may need to configure your Xbees using this program:
http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/xctu
Most Xbee radios come defaulted to work out the box at 9600 baud (default Mbed speed), however you can change many settings including sleep and baud rate functions.
The Xbee will need approximately 60mA in wake up mode (transmit or receive) and only a few uA's in sleep mode. To save power you can put the Xbee to sleep when not transmitting or receiving but allow 50mSeconds to wake up. But will need to enable the sleep function on the Xbee.