View Full Version : I got my XBee's working!

Kevin SkyMoCo
02-06-2010, 03:05 PM
I really like the new Parallax USB XBee adapters. Having LED's for more than just the power is very helpful and it makes my office look like the holidays. In just a couple weeks of playing around I've gotten one XBee connected to a stamp out in the shop with a temperature/humidity sensor talking to another one here in the house graphing the data on my computer. My next steps to to make an wind speed sensor and have it send that data to me as well.

I'm am absolute novice at all this. I had a couple stamps sitting around for the last 6 years and only after I happened across an article on the XBee's did I get interested.

I did find out that if you leave your stamp outside overnight and it rains it might not work anymore in the morning. I guess one of the next steps better be a weatherproof enclosure.

02-06-2010, 06:08 PM
Kevin SkyMoCo said...
I did find out that if you leave your stamp outside overnight and it rains it might not work anymore in the morning.
Yes, that's the special remote rain sensor function. It's an undocumented feature.

Congratulations on the XBees - interesting to see that's what got you to pull out the Stamp. I bought a "What's a Microcontroller?" kit with the Homework Board from Radio Shack years ago, played with it three or four times and then put it away for a couple of years, and then really dived in when I discovered GPS modules and RF modules at about the same time.

Ron Czapala
02-08-2010, 02:38 AM
How did you handle the 3.3v / 5v difference on the signal lines between the XBee and the Basic Stamp?

It doesn't look like the Parallax XBee Adapter Board handles the voltage difference. Could you describe your wiring or provide a schematic?


Kevin SkyMoCo
02-08-2010, 11:36 AM
On the stamp side I used one of these adapter boards which does the voltage conversion. http://www.ladyada.net/make/xbee/. It works fine as long as the the board of education that I am using is attached to house power. I was thinking of going with two power sources out in the field, a set of two rechargeable batteries for the XBee and three for the stamp but that's the next step and I have no idea how that will work. My goal is to put this on top of a hill a couple thousand feet away and read the temp and wind speed remotely.

So, the local XBee is using the Parallax USB adapter board attached to a USB port of a little linux box. I am using the java API "xbee-api" to read the data and put it into a derby database along with a time stamp and other details like the signal strenth of each packet. On my windows machine I wrote a java program to grab the data from the database and graph it. The remote XBee is plugged into the adapter board noted above on a board of education with the Sensirion SHT11 sensor. Right now it's in a metal outbuilding about 200 yards away from the house and the signal strenth is really good. Over the next few days I want to implement the sleep mode on both the XBee and the stamp and do my samples every 5 minutes or something like that. Right now I sample a couple times a second which is overkill for sure.

I'm using the API mode on the XBee's. I just send the raw data from the Sensirion in a packet encoded into the ascii version of the number. So to send 4256, I send "4", "2", "5" and "6". This is 0x34 0x32 0x35 0x36 in hex so it is easy to dump the raw data and see what is going back and forth and I don't have to do any fancy escaping of the data. I'm just feeling my way along but it's working...

If your interested in all or any of my code I can post it or send it to you.

Ron Czapala
02-08-2010, 06:43 PM
·· Thanks for the prompt reply. I've been investigating XBees and adapter boards like those
from Selmaware http://www.selmaware.com/appbee/index.htm·and/or
using·a logic level converter from Sparkfun http://www.sparkfun.com/commerce/product_info.php?products_id=8745

Are you using the 1mw XBees or the 63mw? There is a big difference in power consumption but I am leaning toward the 63mw versions...

- Ron

Kevin SkyMoCo
02-08-2010, 09:40 PM
I'm using the XBee pro's. The 63mw as I would like one of my wind sensors to be 2000-2500 feet from me. I'm a little worried it will make it and hope to test it in the next day or so. Now I can graph the received signal strength I was going to take a walk with the XBee and time my travels and hopefully that will tell me where the best placement is.

Tracy Allen
02-08-2010, 11:29 PM
Ronczap, note that Selmaware Appbee-MOD and the Appbee-SIP already have level converters and the 3 volt power supply on board. He also has adapters without the extras for use with the 3.3V Propeller.

I needed to be able to plug XBees directly into a DB9S DEBUG connector on the Stamp, so I made my own adapter (attached) using a CD4049 as the level shifter. (The CD4049 has 5V tolerant inputs and provides signal inversion.)

Consider your application before you decide to go with the Pro. . Do you really need the extra range and power? The longest range comes with the 900MHz XB09 series. There is a page on antenna's and gain at www.digi.com/technology/rf-tips/2007/08.jsp (http://www.digi.com/technology/rf-tips/2007/08.jsp) and there is also Digi app note 10a on antennas and range.

Tracy Allen
www.emesystems.com (http://www.emesystems.com)

02-09-2010, 12:06 AM
Tracy -

I'm curious about that LT1521 you're using to power the XBee. The datasheet says it provides 300mA. An XBee Pro requires 215mA during transmit (again, per the datasheet). Do you worry about having enough "margin", as it were?

Similarly, you have Vin as 3.3-15 VDC. Does the .5V dropout mean that you really need at least 3.8VDC for Vin? And do you have to worry about heat dissipation when you get up to the higher voltages? I've been nervous about putting 9V into a TO-220 3.3V output regulator. Am I being too concerned?

Picking regulators has been a considerable issue for me.

The CD4049 is powered by the 3.3V supply, but can connect to 5V through the DB9?
Kevin -

You were able to use the LadyAda XBee board with an XBee Pro? I've got one of those boards, but the extra tab down the bottom of the XBee Pro goes right where that capacitor and transistor at the bottom of the board stick up, so I wasn't able to mount it (regular XBees fit fine, like in the product photo). Did you do something special, or maybe they've changed the design of the board?

Kevin SkyMoCo
02-09-2010, 12:17 AM
I just put in the cap and transistor at right angles and it all fit. :)

Ron Czapala
02-09-2010, 12:24 AM
Thanks for insight and the schematic. I noticed that the AppBee adapters use a tristate 74LVC244A level shifter that handles 5v and 3.3v at the same time.
Your circuit is applying 3.3v to the CD4049 IC correct? I guess a basic stamp would recognize a 3.3v serial signal - doesn't need to be 5v?

"Inputs can be driven from either 3.3V or 5V devices. In 3-State operation, outputs can handle 5V. These features allow the use of these devices as translators in a mixed 3.3V/5V environment."

The level shifter from sparkfun uses a BSS138 transistor and a voltage divider circuit. I already have one these but would have to order either of the other ICs.

I've browsed the www.digi.com site and sparkfun's offerings. It's amazing that one transceiver can range 40 miles (for a mere $185)!

I am going to experiment with my sparkfun level shifter, a BS2 and my oscilloscope to see what voltages I get and then decide whether to try the other circuits and which XBee models to order.

Do you know if the wire antennas give a better range than the chip antennas?

Thanks again

02-09-2010, 12:41 AM
Digi has a white paper out on the range of the various modules with the different antennae:


(click on the .pdf at the bottom)

Their conclusion is that when used indoors, the chip vs. whip makes no difference to range at all, but when used outdoors, it makes a BIG difference (in favor of the wire whip antenna). The wire antenna roughly doubles the outdoor range of a regular XBee, and does even better than that for the range of the XBee Pro (again, according to Digi).


Ron Czapala
02-09-2010, 01:23 AM
Thanks for link - I was searching for XBee antenna comparison info this morning and had no luck.
I just ordered two XBee Pros, the USB adapter board and 2 of the other adapter boards. Looks like a bit of a learning curve...

Fun city!

Tracy Allen
02-09-2010, 02:56 AM
I wonder how the 1/2 wave RPSMA or U.Fl rubber duckie antennas stacks up against the chip and wire whip? The app note does not include it, but it offers 2.1 dB gain against 1.5 dB for the wire whip. The main thing is to get it high off the ground. Speaking of high off the ground, Sylvie369, which XBee and antenna are you using for your rocket and ground stations?

Here are index pages for Digi's white papers and application notes. Kind of scattered.
Here is a direct link to a white paper on maximizing range (http://ftp1.digi.com/support/images/XST-AN010a-Maximizing%20Range.pdf%20(712.29KB).pdf)

Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Tracy Allen
02-09-2010, 03:56 AM
The CD4049 is a special CMOS buffer that tolerates +15 volts on its inputs no matter what the supply Vdd. So it translates from Stamp 5 volts to XBee 3 volts. The 150kOhm Rs on the inputs are extra protection, in case the adapter gets plugged into a PC serial port via a null modem adapter. The Stamp input threshold is around 1.4 volts, so a 3 or 3.3 volt output from the module gives plenty of margin.

The LT1521-3 has just enough oomph to run an XBee pro, and the SOT223 package soldered to a good pcb area can handle the power dropped from a 5 volt supply down to 3.0 volts. The hard current limit is typically 400 mA. A main reason I use the LT1521 is for its low quiescent current, 12µA when the XBee is asleep. I'm fanatic about counting microamps for long term deployments!

Earlier XBee data sheets warned that the quiescent current at 3.3V was substantially greater than at 3.0 volts, but they dropped that warning from the most recent data sheet--Need to verify. For a standard XBee, with its peak current of 50 mA, the allowable supply range to the regulator is wider. XBees run on Vdd from 2.8 to 3.4 volts.

Another regulator I've used with these is the LT1129-3.3, also in the SOT223 package, rated at 700mA peak and 50 µA quiescent current.

Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Post Edited (Tracy Allen) : 2/8/2010 9:03:27 PM GMT

Ron Czapala
02-09-2010, 04:16 AM
· I'm not sure what the implications are for quiescent current values.· I ordered these· 3.3v voltage regulators from Parallax.
I assume they will work fine with the XBee but I wonder if they should be fed from the main source or piggybacked onto the regulated 5V VDD from a basic stamp board?


The LM2937-2.5 and LM2937-3.3 are positive voltage regulators capable of supplying up to 500 mA of load current.
Both regulators are ideal for converting a common 5V logic supply, or higher input supply voltage, to the lower 2.5V and
3.3V supplies to power VLSI ASIC’s and microcontrollers. Special circuitry has been incorporated to minimize the quiescent
current to typically only 10 mA with a full 500 mA load current when the input to output voltage differential is greater than 5V.
Thanks for your help!

Chris Savage
02-09-2010, 05:09 AM
As a head's up, Parallax does have an adapter board coming out soon which does have the level translation on it. It also includes a voltage regulator providing 3.3V from 5V. They'll be available for sale in under two weeks.

Best Regards,

Chris Savage

Parallax Engineering
Check out the new Savage Circuits TV! (http://www.youtube.com/savagecircuits)

02-09-2010, 05:30 AM
Wow - lots of good information here. That's good news about the level translation board.

Tracy - on the rocketry project all of my XBees are 2.4GHz Series one XBee Pros with the wire antenna. As I mentioned elsewhere, I'm getting perfectly good data from one mounted inside a cardboard tube doing 450 MPH 3000 feet over my head.

In the not-too-distant future I intend to try transmitting from the ground to an XBee in that situation (well, after it has slowed down considerably). It'll be interesting to see if it works in that direction as well.

Ron - this should flatten out the learning curve quite a bit:


(Martin Hebel's excellent introduction to the XBee)

Ron Czapala
02-09-2010, 06:07 AM
It's funny that you sent the AppBee doc link to me since I ordered 2 of the SIP boards earlier this afternoon.

My only issue is that the SIP boards have connecting pins for a PropPlug and the MOD board uses the USB2SER adapter (I have two USB2SERs - no PropPlug)

I will use the USB XBee Adapter for setting up the XBee and them move them to the AppBee board.
I wish I had known Parallax was coming out with a level shifting adapter - I would have waited!!
- Ron

Ron Czapala
02-21-2010, 08:05 AM

I bought some CD4050 (non-inverting) CMOS buffers per your recommendation·for level shifting between the Basic Stamp and the XBee.

I hooked one up to a BS2 and my oscilloscope and used serout commands to check out the voltages.

It works great and should make it simple to use with the XBee digital and analog I/O pins.

Thanks for the suggestion!

- Ron

Tracy Allen
02-21-2010, 08:22 AM
I'm glad that worked out! I used the CD4049 (same as the CD4050, except inverting instead of non-inverting). I did that becauset I wanted to be able to plug it into a standard serial port or into the Stamp debug port, which alway invert the signals, and need to be re-inverted to go into the XBee.

Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Ron Czapala
02-21-2010, 08:39 AM
Your schematic was helpful but I realized I needed the CD4050 instead.

I am actually using the AppBee adapter boards for the RS232 signals but wanted to be able to utilize the analog/digital pins which the AppBee doesn't condition.

I am using the ATDB command to·display the received signal strength on an LCD but haven't really tested the actual range yet. I doubt that·they will actually work a mile apart but we'll see...

Martin Hebel
02-22-2010, 11:34 AM
Chris Savage (Parallax) said...
As a head's up, Parallax does have an adapter board coming out soon which does have the level translation on it. It also includes a voltage regulator providing 3.3V from 5V. They'll be available for sale in under two weeks.

Best Regards,

Thanks for putting me out of business Parallax.... So does this mean I don't have to spend my nights soldering anymore? Guess it's time for a clearance sale - Yay!

SelmaWare Solutions

Kevin SkyMoCo
02-27-2010, 04:39 AM
Chris Savage (Parallax) said...
As a head's up, Parallax does have an adapter board coming out soon which does have the level translation on it. It also includes a voltage regulator providing 3.3V from 5V. They'll be available for sale in under two weeks.

Best Regards,

OK, it's been almost three weeks and my money is burning a hole in my pocket? Will they be ready soon?

02-27-2010, 05:31 AM
Just for a real world example of range using the Xbee Pro modules - I have 3 "remote" 900MHz Xbee Pros currently reporting to a single 900MHz "base-station" Xbee Pro. All the radios are connected to Tracy's adapter board and then to an OWL2pe (Basic Stamp 2pe). The radios are all running with the Point-to-Point firmware (XBP09-DP) and are using dipole antennas. The base and all 3 remotes are approximately 30 feet off the ground mounted on galvanized poles. Each remote radio is talking back and forth to/from the base radio over a vineyard once every 15 minutes. The 3 remote radios are approximately 0.1 mile, 0.3 mile and 0.8 miles from the base station. All 3 report just fine, but, understandably, I do see more packet loss from the unit that's 0.8 mile away.

In another location, I have the same setup, but in an almond orchard. Here, the branches from the trees are just under the 30' height where the Xbee Pros are mounted on the poles. This means the Fresnel curve is not appreciated fully. But, there is line of site from the "base" station to 2 different "remote" stations, each about 0.8 mile away in opposite directions from the base. One of the 2 sites has great packet delivery/reception characteristics, while the other can't communicate with the base at all. It just goes to show that there's a lot of trial and error to finding what works and what doesn't.

Kevin SkyMoCo
02-27-2010, 10:44 AM
I have one XBee in the house and another in the shop. I wrote this little application which logs the RSS values. I was surprised how much things like putting the XBee in the window and opening and shutting the garage door made in the signal. Having the florescent lights on in the shop even changes things. I'd love to see other people's stamp code if you are using API mode, mine is pretty simplistic but it works.

I load up my XBdata0-3 values and a XBRecType variable and send it with this subroutine. The Frame numbers go from 97-122.

'XBAPI = 1 ' This is a transmit packet
DEBUG "Data Packet to Xmit: ", DEC XBPacket, CR
XBFrame = XBFrame + 1
IF XBFrame > 122 THEN
' Keep our values above values we might have to escape, and encode them in
' something meaningful along the way
XBData3 = 48 + ( XBPacket DIG 3)
XBData2 = 48 + ( XBPacket DIG 2)
XBData1 = 48 + ( XBPacket DIG 1)
XBData0 = 48 + ( XBPacket DIG 0)

' Calculate the checksum, this will overflow a byte, but, hey, that's what I want
XBCheckSum = XBAPITx + XBFrame + XBDestLow + XBDestHigh + XBRecType+ XBData3 + XBData2 + XBData1 + XBData0
XBCheckSum = 255 - XBCheckSum

DEBUG "Packet Type(", IHEX2 XBAPITx, ")", CR
DEBUG "Frame Counter: ", DEC XBFrame, CR
DEBUG "Packet Destination: (", IHEX2 XBDestLow, "), (", IHEX2 XBDestHigh, ")",CR
DEBUG "Options: ", IHEX2 XBOptions, CR
DEBUG "Record Type: (", XBRecType, ")",CR
DEBUG "Data: (", XBData3, "), (", XBData2, "), (", XBData1,"), (", XBData0,")",CR
DEBUG "Checksum: ", DEC XBCheckSum, CR
SEROUT XBTxPin, XBBaud, [126,0,10,XBAPITx,XBFrame,XBDestLow,XBDestHigh,XBOp tions,XBRecType,XBData3,XBData2,XBData1,XBData0,XB CheckSum]
'SEROUT XBTxPin, XBBaud, [126,0,10,1,125,51,170,170,0,1,1,2,3,4,140]
' TX Good Status packet should look like: 126,0,3,137,XBFrame,0,34
SERIN XBRxPin, XBBaud,3000,main2, [WAIT(126),SKIP 2,WAIT(137),XBData0,XBResult, SKIP 1]
DEBUG "Packet:", DEC XBData0, ", Tx Result: ", IHEX XBResult,CR