XBee Level Shifting

The XBee communication (RX/TX) pins definitely operate off of a 5V signal with the Arduino. We’ve seen this a lot and done this a lot, and it certainly keeps things simple. That said, there’s nothing wrong with adding a level-shifting circuit to deliver 3.3 V signals to the XBee and 5 V signals to a microcontroller.  Definitely a good idea for commercial applications where you will need to keep the module stable across its entire temperature range, etc.

Level shifting can be accomplished with:

  • a resistor-based voltage divider: This will work but will also slow down signal rise and fall times significantly. For most cases this won’t be a problem, but it might affect the integrity of fast signals over long wires.
  • a Zener circuit (with a resistor for level-shift): This is better but the part isn’t one most people have lying around, and it’s not stocked say, at Radio Shack
  • a diode circuit:  The two in the schematic below use easily available parts and the diodes can be any common silicon rectifier type

Thanks to Zach Eveland for providing this helpful diagram and details.

8 Comments on “XBee Level Shifting

  1. In the last drawing (5v-out to 3v-in) shouldn’t D3 and R2 be switched around (with D3 cathode to 5v-side)? As I understand it now, the 3v input wil actually be at around 4 volts. (3.3v supply + 0.7 voltage drop, as the 5v output feeds the 3.3v supply through D3) It may be safe in practise, but I have not found any official information from Digi that XBees are tolerant to more than 3.3 volt.

    When switched around, D3 blocks current from the 5 volt output if that is high, while the 3v input is pulled high to the 3.3v supply. When the 5 volt output goes low, then the 3v input is left at the voltage drop across D3. (as now current flows from 3.3v supply through R2 and D3) The voltage drop should be below ViL of the Xbees (<1 Volt).

  2. Very true (though using a Schottky for D3 mitigates this problem). However, as you note, your suggested circuit has the opposite problem: “low” on the 3V side is around 700 mV (around 300 with a Schottky) instead of 0V. Especially with student circuits, I’ve seen more problems caused by low signals being out-of-spec: many low-voltage parts have unadvertised 5V-tolerant IO but can’t cope with a “low” that is a few hundred millivolts. Add in the ohmic signal paths on a breadboard that has seen some abuse and, for prototyping at least, I recommend erring on the high side.

    The top circuit has this problem too but 5V parts tend to be more forgiving on IO levels. I don’t love this approach though: it mostly serves to bias the input signal up a little and doesn’t achieve very high “highs” or low “lows”. Any suggestions?

  3. Thanks Rob,

    the circuit works nicely.

    I needed it because I had a level-related issue between my Arduino UNO and an XBee mounted on the XtremeBee adapter, and the comunication was not working as expected. Now all runs smoothly…

    Regards.

  4. Best things to do is put an OpAmp for level-shifting. Solutions above are not suitable when working with PIC, where minumun high input voltage is often 0.7-0.8 * Vdd (3.5-4 volts when powered at 5 volts). An OpAmp powered with the desidered output voltage will erase all the problems.

  5. Works like a charm, i also used all schottkys, as with silicon 4148 diodes i got 3.8V for DIN and DOUT, whereas BAT85 gives 3.5V, only very slightly above the documented max voltage (XBee datasheet says supply voltage 2.8 to 3.4V but nothing about data lines tolerance except the thresholds for “guaranteed read as 0/1” values)

  6. I also left out R1 as it’s a very space-constrained aplication and instead enable the internal pullup of ATmega. Seems like my FTDI adapter also has one as it too works without R1 and 5V_INPUT still reads 5V

  7. Let me see if I understand the first circuit.

    When 3.3V output is high, the 5V input will be about 1 diode drop higher than 3.3v, right? Usually high enough. At the same time, the 3.3V output won’t itself be pulled higher than about 3.3V (unless D2 and only D2 is Schottky).

    D1 is then needed to prevent 3.3V being shorted to ground by the 3.3V output when low.

    Side effect: About 170 uA flows continuously from 5V to regulated 3.3V.

    Is that right?

Leave a Reply to Fida khan Cancel reply

Your email address will not be published. Required fields are marked *

*