Light Switch XBee Example Project-Series 1
Light Switch XBee Example Project-Series 1
com 8/24/11
The Light Switch XBee is a wireless wall switch that can control lamps, fans, motors or
your homemade robot. This project can serve as a model for almost any digital input
device you’d like to build. You can substitute any number of digital inputs, like a
pressure mat, magnetic contacts or even a soft switch made of conductive fabric in its
place. If it goes on and off, now you can make it wireless!
Parts
AF is Adafruit, DK is Digi-Key, RS is Radio Shack, SFE is SparkFun Electronics.
• 1 PVC Light Switch Kit (Wiremold/Legrand NM2-S or similar, available from Ace
Hardware, Home Depot and many other retailers. See Figure 1)
…or any single pole light switch, plastic enclosure and plastic faceplate. (Metal
enclosures will significantly attenuate the radio signal, but may work for short-range
solutions.)
• Hook-up wire or jumper wire kit (AF 153, DK 923351-ND, SFE PRT-00124)
• 1 3-volt lithium battery (CR123A is a good choice)
• 1 battery holder (DK BH2/3A-3-ND works with CR123A)
• 1 10K Ohm resistor (DK P10KBACT-ND, SFE COM-08374)
• 1 XBee Series 1 802.15.4 radio, configured with version 10E8 or later (Digi: XB24-
AWI-001, DK XB24-AWI-001-ND).
• 1 XBee breakout board with 2mm female headers installed (AF 126, SFE BOB-
08276 & PRT-08272)
1
Rob Faludi, http://faludi.com 8/24/11
• XBee USB Serial adapter (XBee Explorer, Digi Evaluation board or similar) (AF
247, SFE WRL-08687)
• USB cable for XBee adapter (AF 260 , SFE CAB-00598)
• Wire strippers (AF 147, DK PAL70057-ND, SFE TOL-08696)
• Soldering iron (AF 303, DK WES51-ND, RS 55027897, SFE TOL-10553)
• Solder (AF 145, RS 64-025, SFE TOL-09163)
• Helping hands (AF 291, DK 243-1018-ND, RS 64-079, SFE TOL-09317)
2
Rob Faludi, http://faludi.com 8/24/11
When you’re finished, check your work by reissuing each AT command without any
parameter so the radio can show you the addresses and register settings that it’s using. As
a final step, use the ATWR command to write the new configuration to your radio’s
firmware so it’s saved for the next power-up.
Don’t forget to check your work, and to issue the ATWR command to write the new
configuration to your radio’s firmware so it’s saved for the next power-up.
3
Rob Faludi, http://faludi.com 8/24/11
2. Test-fit the XBee into the female sockets, being careful not to bend its pins (see
Figure 2).
Soldering Tips
If you’re new to soldering that’s great! It’s very easy to learn. Check out some of the
many example videos online and practice soldering a few wires together before you start
on the steps below. Good solder joins are key to making this project work reliably. Use
the helping hands to position and hold the wires and components in place while you
solder. It’s worth some patience to get them positioned well before starting. It may be
helpful to twist together two wires that go to the same connection point so that one or the
other doesn’t fall out of place while you’re soldering. Make sure you heat the wires, pins
and leads all at once, and only then touch the solder to the components to flow it over
everything. While it’s tempting to melt solder onto the iron itself and then “paint” it on to
your connections, this will typically result in poor joins that either don’t connect at all or
crumble apart very easily.
XBee Connections
1. Solder a 10K ohm resistor between pin 10 (GND) of the XBee breakout board and
pin 20 (AD0). It may be helpful to insulate the leads of the resistor so that it does not
touch other pins by accident. Stripping a bit of insulation off one of your hookup
wires and sliding it over the resistor’s leads is one way to accomplish this (Figure 3).
2. Use black hookup wire to connect pin 10 (GND) of the XBee to the negative
terminal of your battery holder.
3. Use red hookup wire to connect pin 1 (VCC, 3.3V) of the XBee to the positive
terminal of your battery holder (see Figure 4).
4
Rob Faludi, http://faludi.com 8/24/11
5
Rob Faludi, http://faludi.com 8/24/11
Ignore any green (ground) terminal on the light switch. External grounding
isn’t needed for low-voltage applications. If your light switch has other
terminals, consult the schematic that came with it, or use continuity test
mode on a multi-meter to find two terminals that connect and disconnect
when the switch is thrown.
6
Rob Faludi, http://faludi.com 8/24/11
7
Rob Faludi, http://faludi.com 8/24/11
8
Rob Faludi, http://faludi.com 8/24/11
Parts
• 1 solderless breadboard (MS MKKN2, AF 64, DK 438-1045-ND, SFE PRT-09567)
• Hook-up wire or jumper wire kit (AF 153, DK 923351-ND, SFE PRT-00124)
• 1 3-volt lithium battery (CR123A) and…
• 1 battery holder (DK BH2/3A-3-ND works with CR123A)
…or
• 2 AA battery holder with connection wires (RS 270-408, SFE PRT-09547) and…
• 2 AA batteries (alkaline or NIMH rechargeable, fully charged) (RS 23-873, SFE
PRT-09100 or PRT-00335)
• 1 5mm LED (DK 160-1707-ND, RS 276-041, SFE COM-09590)
• 1 XBee Series 1 802.15.4 radio, configured with version 10E8 or later (Digi: XB24-
AWI-001, DK XB24-AWI-001-ND).
• 1 XBee breakout board with male headers and 2mm female headers installed (AF
126 (add SFE PRT-00116), SFE BOB-08276 & PRT-08272 & PRT-00116)
• XBee USB Serial adapter (XBee Explorer, Digi Evaluation board or similar) (AF
247, SFE WRL-08687)
• USB cable for XBee adapter (AF 260 , SFE CAB-00598)
• Wire strippers (AF 147, DK PAL70057-ND, SFE TOL-08696)
When you’re finished, check your work by reissuing each AT command without any
parameter so the radio can show you the addresses and register settings that it’s using. As
9
Rob Faludi, http://faludi.com 8/24/11
a final step, use the ATWR command to write the new configuration to your radio’s
firmware so it’s saved for the next power-up.
10
Rob Faludi, http://faludi.com 8/24/11
11
Rob Faludi, http://faludi.com 8/24/11
Actuator Example
Would you like to turn on and off A/C mains powered appliances? Chapter 6 of
“Building Wireless Sensor Networks” (http://faludi.com/bwsn/) concludes with a Direct
Actuation example that uses the PowerSwitchTail A/C relay shown in Figure 6
(http://powerswitchtail.com/). You can use the Actuator Boards show in that example
with the Light Switch XBee. Simply replace the Series 2 ZigBee radio discussed in the
book’s example with a Series 1 XBee configured as a Simple Receiver (above). Now
your light switch can switch on your lava lamp, spin your disco ball or fire up your
daiquiri blender.
Summary
This Light Switch example is just the beginning. You can use the same circuit and radio
configuration to create a security alarm, for example, by substituting a pressure mat for
the wall switch. Or invent your own switch using any two pieces of metal or conductive
material. Maybe you want shoes that turn on your toaster. Or a cat door that plays “The
Cat Came Back” each time Fluffy returns from an outing. Even complex sensor ideas can
often be boiled down to a simple switch solution. Start making stuff!
12