Using Xbees to control relays

In this video we show you how we control two different types of relays, wirelessly, using Xbees (m4v & iTunes). If you’re on the wireless fence and want to jump over to the Xbee side, we have adapter kits, modules and more

Parts used (all from digikey, but available elsewhere as well): Standard relay, latching relay, 1N4001 (standard), PN2222 (or any NPN transistor), hex inverter 74HC04 (any inverter or buffer will do, suggest HC family)
Parts used from adafruit: 2 XBee series 1, 2 XBee adapters.
To configure, see “Configuring radios to pass Digital I/O”
The receiver schematic is here but note that its pretty ‘basic’ in that you’ll probably want to tweak it for your design anyways.
The transmitter is just an XBee adapter with two buttons on DIO1 and DIO2 to ground (it has internal pullups by default)

Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here:

Join Adafruit on Mastodon

Adafruit is on Mastodon, join in!

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 36,000+ makers on Adafruit’s Discord channels and be part of the community!

CircuitPython – The easiest way to program microcontrollers –

Maker Business — “Packaging” chips in the US

Wearables — Enclosures help fight body humidity in costumes

Electronics — Transformers: More than meets the eye!

Python for Microcontrollers — Python on Microcontrollers Newsletter: Silicon Labs introduces CircuitPython support, and more! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

Adafruit IoT Monthly — Guardian Robot, Weather-wise Umbrella Stand, and more!

Microsoft MakeCode — MakeCode Thank You!

EYE on NPI — Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — #NewProds 7/19/23 Feat. Adafruit Matrix Portal S3 CircuitPython Powered Internet Display!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at !


  1. can you post schematics and part numbers for items used in this demonstration?

  2. Oh, is there any way to monitor status on the control side of this setup?

  3. Nice demo! I second the request for the circuit and parts.

    To monitor status you could introduce a micro and use the Remote AT capability of XBees. Or for even better performance/reliability, put a micro on each XBee and you can get ACK of your on/off commands and query. But now you’ve lost what was so nice about this solution — simplicity.

  4. I have an application where I’d like to know the state of the device once I’ve sent a relay command to it. eg: gate open/ gate closed?

    I assume that I should RTFM.

  5. Can you make the schematic bigger than a thumbnail? Thanks.

  6. @alcurb – click the thumbnail… for the folks who requested the schematic, it’s up now — please build it, post photos – many times folks demand a lot of documentation, even for a quick a video like this but rarely actually build something, so please go make something cool and share it 🙂

  7. Can you explain the buffering concept, and why the transistor and hex buffer are required between the XBee and the relays? Thanks!

  8. @GDR the xbee I/O’s can only supply ~2mA. Relays need 10 – 100 mA. Thus a buffer is required. Much like how a microcontroller cant power a motor, you need a motor control chip which is essentially a big buffer.

  9. Thanks for posting this. I like videos and blog posts like this that explain something in wide enough terms that it can be applied to a number of different applications. Gets people thinking about how they could use this in their projects.

  10. Thanks for posting the details!

    Got some ideas brewing already!

    Does anyone know of a serial port analyzer that would allow me to determine baud and bit format? I’ve got a product that appears to communicte in the 300 baud range, but I’m not sure.
    If it does, is there simple way to upconvert to a baud rate that the Xbee can talk in?

  11. Robert Boerner

    Another neat demo. Not related to the circuit, but audio…

    If the camcorder you are using to film has an extra audio in, you should put a mic on ladyada. Throughout most of the demo videos I have watched, there is a noticeable volume jump as the camera pulls in to show close-ups. It is also kind of hard to hear when the camera is far away. B&H Photo has relatively inexpensive wireless lavalier mics that will work well enough. They are only about 4 miles away from you guys I think…

  12. I put my money where my keyboard is and bought some Xbee adapter boards. I don’t think I would have if you hadn’t posted this demo.

    Keep up the good work. The updates have yeilded all sorts of cool stuff I’ve enjoyed looking at.

  13. hi robert – we have a few different mics and have visited b&h many times 🙂

    sometimes the videos are short and quick, other times we spend a lot of time on mic’ing up, lighting, etc – since the volume is always at a level that’s audible we think for these quickies, it’s ok – for other videos we’ll spend more time – thanks for the feedback, we’ll try and see what else we can do.

  14. @Scienkoptic – thank you so much!

  15. Someone needs to sell short RP-SMA M-F patch cables!

    I’d pay more not to have to buy from china. It’s nice to get stuff within a week or two of when you ordered.

  16. Slightly off topic, but, what software are you using to create the schematics you published? As the saying goes, the devil is in the details, and documentation is all about the details.

  17. I had been looking over the various features on the Xbees previous to this video. Do the analog ports work in the same way? It would be nice to have a remote standalone Xbee do data collection for an Arduino project I’m working on. I just hadn’t got around to experimentation yet.

    The Adafruit Xbee adapter boards work very well. If you are using the Xbee Pro boards, I would recommend substituting a shorter, fatter electrolytic capacitor. The Xbee Pro boards are about 1/4″ longer and interfere with the 100uF electrolytic and voltage regulator. Or simply make soldering in the electrolytic capacitor opposite the voltage regulator the very last thing you do after installing the Xbee Pro so you can get it angled right. The voltage regulator bends over just fine.

  18. I need to use XBeePRO for my Unmanned Ground Vehicle Project. Can i use it with the XBee Adapter Kit. Also i need Serial Data ?? Please help.

  19. Is there a way to do this without the hex inverter? Say directly off the digital outputs of an arduino. I have an xbee shield talking happily to the arduino, and just want to switch the latch without additional components, if possible. Arduino should source 40ma which is what the latch relay needs…

  20. sure but then you’d need to add a $30 arduino 🙂

  21. BTW, I might be a retard, but the pointer to “latching relay” on digikey above directs you to a part which is labeled DK1a-L-5V-F, which is somewhat different from the DK1a-L2-5V-F. Your circuit seems to use a double coil latching part with each of your inverter segments connected to a different coil on pins 3 and 5..which seems to be pins 5 and 6 on the Panasonic datasheet. The “L-only” one has only four pins and seems to latch through reverse polarity in some way that I can’t quite figure out.

  22. Hey, i dont know how to connect the push buttons to xbee module(what pins are used?), and the same at the receiver(where do i connect the pins?), i’m using the xbee starter kit.

  23. Can a funnel IO board with xbee radio send commands to read and write to an xbee radio attached to a relay? If so, how does arduino code send AT commands to the remote relay with xbee radio?

  24. Where is the code to do this ? I would like to be abe to send the commands from my computer instead of from the buttons… thanks Randy

  25. To Jose and Randy, I hope y’all found the info you needed. If not, I know a little about sending remote commands (send over RF) to the XBee chips from Digi. Pretty simple but requires API mode on the sending chip. If you need more information email me.

  26. Hi that’s a really cool project, I’m in my way to xBee I just have a quick question:

    I was checking your schematic and I saw one relay powered by the transistor, I think that I can use the transistor instead of a bunch of buffers right, or I’m missing something?

    thanks a lot for your help I appreciate it.

  27. Testing out the catcha 🙂

Sorry, the comment form is closed at this time.