Wirelessly control lights and motors using xbee communication! – maker challenge – teachengineering t gastrobar


• 2 XBee Series 1 trace antennas, for $25 each at SparkFun; many different types of XBees are available and several different antenna options are available with the more expensive ones extending the range from feet to miles; the Series 1 XBee is highly recommended for this activity due to its ease of configuration and classroom range

Have you mastered the nuances of serial communication and controlled a servo remotely with your computer but now you want to operate the servo from hundreds of feet away without a cable? Maybe you want to send data from an electric fence that is miles away to alert you that something has run into it? Or perhaps you want to make your own remote-controlled vehicle? If you have an interest in wireless communication, XBee radio communication modules are for you.

So many applications are possible! Remote sensing systems are employed to determine and control all sorts of everyday items. Is someone occupying that hotel room? Is a specific cabinet or garage door open or closed? Are the lights at a distant location on or off? Typical industrial uses include remote water and air monitoring systems that use sensors and wireless communication to measure and report data about usage, levels, flow and chemical composition. All these systems are examples of the “Internet of things.”

Once XCTU discovers the device, drag the device from the left to the right window in order to see the radio configuration settings. Many numbers can be configured for XBees. The nice thing is that for basic configuration, only three fields are necessary. The important settings are:

Have a pen and paper handy to record these numbers. Make the ID the same for both XBees; DL and MY can be any four-digit numbers you choose. Once you enter the numbers, save the information on the XBee using the XCTU “Write” (pencil) icon. Then “Read” from the XBee to verify that that the changes are saved.

Next, unplug the Explorer, remove the first XBee and plug in the second XBee. The configuration of the second XBee is the exact same as the first XBee, EXCEPT the numbers for DL and MY are swapped. A way to remember this is to think: I am the XBee. MY is “my” number. I am searching for the destination, DL number, of the other XBee. Said another way: The MY number for one XBee is the destination, DL, for the other XBee.

See Table 1 for example numbers for a typical installation. Be careful though! The goal of configuring XBees is to make sure that one XBee pair does not send signals to another XBee pair. An easy way to do this is to have unique ID (PAN ID) numbers for each pair. Another way to ensure that an XBee only communicates with its partner XBee is to give each pair unique DL and MY numbers.

Hint: Set up one XBee pair and then try the Maker Time exercise. Once you have one XBee sending button data to another XBee and blinking an LED, simply swap the XBee pair on the shields to test and ensure that the configurations for the other XBee pairs are correct!

The activity requires each XBee to be placed on an XBee shield, and this shield needs to be placed on an Arduino. So, it works well to team up two groups for this exercise. The sender team reads a button press and sends the output state of the button (that is, whether the button is pressed or not) to the serial monitor. The receiver team receives a one or a zero from the serial monitor and uses this information to turn an LED on and off.

The KEY to coding with XBees is to make sure the switch is in DLINE when you are trying to upload code and UART when you are trying to talk between XBees. You will very likely forget to do this—so, the first thing to check when troubleshooting is the little switch on the shield!

Team 1: Send Sketch—In order to send the information from a button, have the sender team wire a button so that when the button is pressed, a zero appears on the serial monitor, and if the button is not pressed, a one appears. Buttons can be a bit tricky to wire, so be sure to follow the Figure 1 schematic diagram.

• Make sure the breadboard is connected to the Arduino. Often, students connect the button to the breadboard rails, but forget to bring these rails back to the Arduino. Remember: No connections exist between the breadboard and Arduino until you make them!

The KEY to coding with XBees is to make sure the switch is in DLINE when you are trying to upload code and UART when you are trying to talk between XBees. You will very likely forget to do this—so, when troubleshooting, first check the little switch on the shield!

If students use the serial monitor to turn on and off an LED, and the other team reads the button state with the serial monitor (that is, sees values change from 0 to 1 based on the button push/release), the issue lies with the XBee. Suggestions:

The XBee shields do not come with header pins so you need to solder header pins to the XBee shield. See the SparkFun website for soldering tips, but take a look at Figures 7-8 for what the finished soldered shield should look like and how it fits into the Arduino.