You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
12 KiB
HTML
150 lines
12 KiB
HTML
15 years ago
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Arduino - ArduinoXbeeShield </title>
|
||
|
<link rel='stylesheet' href='arduino.css' type='text/css' />
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="page">
|
||
|
<!--PageHeaderFmt-->
|
||
|
<div id="pageheader">
|
||
|
<div class="title"><a href="http://www.arduino.cc"/>Arduino</a></div>
|
||
|
<div class="search">
|
||
|
<!-- SiteSearch Google -->
<FORM method=GET action="http://www.google.com/search">
<input type=hidden name=ie value=UTF-8>
<input type=hidden name=oe value=UTF-8>
<INPUT TYPE=text name=q size=25 maxlength=255 value="">
<INPUT type=submit name=btnG VALUE="search">
<input type=hidden name=domains value="http://www.arduino.cc/">
|
||
|
<input type=hidden name=sitesearch value="http://www.arduino.cc/">
|
||
|
</FORM>
<!-- SiteSearch Google -->
|
||
|
</div>
|
||
|
</div>
|
||
|
<!--/PageHeaderFmt-->
|
||
|
<!--PageLeftFmt-->
|
||
|
<div id="pagenav" style="text-align: right">
|
||
|
<div style="float: left;">
|
||
|
<p><a class='wikilink' href='http://arduino.cc/en/Main/Buy'>Buy</a>
|
||
|
|
|
||
|
<a class='wikilink' href='http://arduino.cc/en/Main/Software'>Download</a>
|
||
|
|
|
||
|
<a class='wikilink' href='Guide_index.html'>Getting Started</a>
|
||
|
|
|
||
|
<a class='wikilink' href='http://arduino.cc/en/Tutorial/HomePage'>Learning</a>
|
||
|
|
|
||
|
<a class='wikilink' href='index.html'>Reference</a>
|
||
|
|
|
||
|
<a class='wikilink' href='http://arduino.cc/en/Main/Hardware'>Hardware</a>
|
||
|
|
|
||
|
<a class='wikilink' href='FAQ.html'>FAQ</a>
|
||
|
</p>
|
||
|
<p class='vspace'></p>
|
||
|
|
||
|
</div>
|
||
|
<a class="urllink" href="http://www.arduino.cc/blog/" rel="nofollow">Blog »</a> |
|
||
|
<a class="urllink" href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl" rel="nofollow">Forum »</a> |
|
||
|
<a class="urllink" href="http://www.arduino.cc/playground/" rel="nofollow">Playground »</a>
|
||
|
</div>
|
||
|
<!--/PageLeftFmt-->
|
||
|
<div id="pagetext">
|
||
|
<!--PageText-->
|
||
|
<div id='wikitext'>
|
||
|
<h2>Arduino Xbee Shield</h2>
|
||
|
<p>The Arduino Xbee shield allows your Arduino board to communicate wirelessly using Zigbee. It was developed in collaboration with <a class='urllink' href='http://www.libelium.com/' rel='nofollow'>Libelium</a>.
|
||
|
</p>
|
||
|
<p class='vspace'></p><h3>A Simple Example</h3>
|
||
|
<p>You should be able to get two Arduino boards with Xbee shields talking to each other without any configuration, using just the standard Arduino serial commands (described in the <a class='wikilink' href='index.html'>reference</a>).
|
||
|
</p>
|
||
|
<p class='vspace'></p><p>To upload a sketch to an Arduino board with a Xbee shield, you'll need to put both jumpers on the shield to the "USB" setting (i.e. place them on the two pins closest to the edge of the board) or remove them completely (but be sure not to lose them!). Then, you can upload a sketch normally from the Arduino environment. In this case, upload the <strong>Communication | Physical Pixel</strong> sketch to one of the boards. This sketch instructs the board to turn on the LED attached to pin 13 whenever it receives an 'H' over its serial connection, and turn the LED off when it gets an 'L'. You can test it by connecting to the board with the Arduino serial monitor (be sure it's set at 9600 baud), typing an H, and pressing enter (or clicking send). The LED should turn on. Send an L and the LED should turn off. If nothing happens, you may have an Arduino board that doesn't have a built-in LED on pin 13 (see the <a class='wikilink' href='http://arduino.cc/en/Main/Boards'>board index</a> to check for sure), in this case you'll need to supply your own.
|
||
|
</p>
|
||
|
<p class='vspace'></p><p>Once you've uploaded the Physical Pixel sketch and made sure that it's working, unplug the first Arduino board from the computer. Switch the jumpers to the Xbee setting (i.e. place each on the center pin and the pin farthest from the edge of the board). Now, you need to upload a sketch to the other board. Make sure its jumpers are in the USB setting. Then upload the following sketch to the board:
|
||
|
</p>
|
||
|
<p class='vspace'></p><pre>
|
||
|
void setup()
|
||
|
{
|
||
|
Serial.begin(9600);
|
||
|
}
|
||
|
|
||
|
void loop()
|
||
|
{
|
||
|
Serial.print('H');
|
||
|
delay(1000);
|
||
|
Serial.print('L');
|
||
|
delay(1000);
|
||
|
}
|
||
|
|
||
|
</pre>
|
||
|
<p class='vspace'></p><p>When it's finished uploading, you can check that it's working with the Arduino serial monitor. You should see H's and L's arriving one a second. Turn off the serial monitor and unplug the board. Switch the jumpers to the Xbee setting. Now connect both boards to the computer. After a few seconds, you should see the LED on the first board turn on and off, once a second. (This is the LED on the Arduino board itself, not the one on the Xbee shield, which conveys information about the state of the Xbee module.) If so, congratulations, your Arduino boards are communicating wirelessly. This may not seem that exciting when both boards are connected to the same computer, but if you connect them to different computers (or power them with an external power supply - being sure to switch the power jumper on the Arduino board), they should still be able to communicate.
|
||
|
</p>
|
||
|
<p class='vspace'></p><h3>A Few Notes</h3>
|
||
|
<p>You can use any of the standard Arduino serial commands with the Xbee shield. With the shield's jumpers in the Xbee position, the print and println commands will send data over the Xbee shield and the USB connection (i.e. to other Xbee shields and to the computer at the same time). In this configuration, however, the board will only receive data from the Xbee shield not from the USB connection (you'll need to switch the jumpers to allow the board to receive data from the computer).
|
||
|
</p>
|
||
|
<p class='vspace'></p><p>The Xbee module on the shield is set up to work at 9600 baud by default, so unless you reconfigure it, you'll need to make sure you're passing 9600 to the Serial.begin() command in your sketch.
|
||
|
</p>
|
||
|
<p class='vspace'></p><p>To allow your computer to communicate directly with the Xbee shield, connect it to an Arduino board whose microcontroller has been removed and place its jumpers in the USB configuration. Then you can send data to and receive data from the Xbee module from any terminal program. This allows you, for example, to see the data that the module is receiving from other Xbee shields (e.g. to collect sensor data wirelessly from a number of locations).
|
||
|
</p>
|
||
|
<p class='vspace'></p><h3>Configuring the Xbee Module</h3>
|
||
|
<p>You can configure the Xbee module from code running on the Arduino board or from software on the computer. To configure it from the Arduino board, you'll need to have the jumpers in the Xbee position. To configure it from the computer, you'll need to have the jumpers in the USB configuration and have removed the microncontroller from your Arduino board.
|
||
|
</p>
|
||
|
<p class='vspace'></p><p>To get the module into configuration mode, you need to send it three plus signs: +++ and there needs to be at least one second before and after during which you send no other character to the module. Note that this includes newlines or carriage return characters. Thus, if you're trying to configure the module from the computer, you need to make sure your terminal software is configured to send characters as you type them, without waiting for you to press enter. Otherwise, it will send the plus signs immediately followed by a newline (i.e. you won't get the needed one second delay after the +++). If you successfully enter configuration mode, the module will send back the two characters 'OK', followed by a carriage return.
|
||
|
</p>
|
||
|
<p class='vspace'></p>
|
||
|
<table width="60%"><tr><td width="50%" valign='top'> Send Command
|
||
|
</td><td width="50%" valign='top'> Expected Response
|
||
|
</td></tr><tr><td valign='top'> <code>+++</code>
|
||
|
</td><td valign='top'> <code>OK</code><em><CR></em>
|
||
|
</td></tr></table>
|
||
|
<p class='vspace'></p><p>Once in configuration mode, you can send AT commands to the module. Command strings have the form <span class='wikiword'>ATxx</span> (where xx is the name of a setting). To read the current value of the setting, send the command string followed by a carriage return. To write a new value to the setting, send the command string, immediately followed by the new setting (with no spaces or newlines in-between), followed by a carriage return. For example, to read the network ID of the module (which determines which other Xbee modules it will communicate with), use the <em>'ATID</em> command:
|
||
|
</p>
|
||
|
<p class='vspace'></p>
|
||
|
<table width="60%"><tr><td width="50%" valign='top'> Send Command
|
||
|
</td><td width="50%" valign='top'> Expected Response
|
||
|
</td></tr><tr><td valign='top'> <code>ATID</code><em><enter></em>
|
||
|
</td><td valign='top'> <code>3332</code><em><CR></em>
|
||
|
</td></tr></table>
|
||
|
<p class='vspace'></p><p>To change the network ID of the module:
|
||
|
</p>
|
||
|
<p class='vspace'></p>
|
||
|
<table width="60%"><tr><td width="50%" valign='top'> Send Command
|
||
|
</td><td width="50%" valign='top'> Expected Response
|
||
|
</td></tr><tr><td valign='top'> <code><span class='wikiword'>ATID3331</span></code><em><enter></em>
|
||
|
</td><td valign='top'> <code>OK</code><em><CR></em>
|
||
|
</td></tr></table>
|
||
|
<p class='vspace'></p><p>Now, check that the setting has taken effect:
|
||
|
</p>
|
||
|
<p class='vspace'></p>
|
||
|
<table width="60%"><tr><td width="50%" valign='top'> Send Command
|
||
|
</td><td width="50%" valign='top'> Expected Response
|
||
|
</td></tr><tr><td valign='top'> <code>ATID</code><em><enter></em>
|
||
|
</td><td valign='top'> <code>3331</code><em><CR></em>
|
||
|
</td></tr></table>
|
||
|
<p class='vspace'></p><p>Unless you tell the module to write the changes to non-volatile (long-term) memory, they will only be in effect until the module loses power. To save the changes permanently (until you explicitly modify them again), use the <strong>ATWR</strong> command:
|
||
|
</p>
|
||
|
<p class='vspace'></p>
|
||
|
<table width="60%"><tr><td width="50%" valign='top'> Send Command
|
||
|
</td><td width="50%" valign='top'> Expected Response
|
||
|
</td></tr><tr><td valign='top'> <code>ATWR</code><em><enter></em>
|
||
|
</td><td valign='top'> <code>OK</code><em><CR></em>
|
||
|
</td></tr></table>
|
||
|
<p class='vspace'></p><p>To reset the module to the factory settings, use the <strong>ATRE</strong> command:
|
||
|
</p>
|
||
|
<p class='vspace'></p>
|
||
|
<table width="60%"><tr><td width="50%" valign='top'> Send Command
|
||
|
</td><td width="50%" valign='top'> Expected Response
|
||
|
</td></tr><tr><td valign='top'> <code>ATRE</code><em><enter></em>
|
||
|
</td><td valign='top'> <code>OK</code><em><CR></em>
|
||
|
</td></tr></table>
|
||
|
<p class='vspace'></p><p>Note that like the other commands, the reset will not be permanent unless you follow it with the <strong>ATWR</strong> comamand.
|
||
|
</p>
|
||
|
<p class='vspace'></p><h3>References</h3>
|
||
|
<p>For more information, see: the <a class='wikilink' href='http://arduino.cc/en/Main/ArduinoXbeeShield'>hardware page</a> for the Xbee shield, the <a class='urllink' href='http://www.squidbee.org/' rel='nofollow'>Libelium SquidBee wiki</a>, and the <a class='urllink' href='http://www.maxstream.net/products/xbee/xbee-oem-rf-module-zigbee.php' rel='nofollow'>MaxStream Xbee page</a>.
|
||
|
The text of the Arduino getting started guide is licensed under a
|
||
|
<a class='urllink' href='http://creativecommons.org/licenses/by-sa/3.0/' rel='nofollow'>Creative Commons Attribution-ShareAlike 3.0 License</a>. Code samples in the guide are released into the public domain.
|
||
|
</p>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
<!--PageFooterFmt-->
|
||
|
<div id="pagefooter">
|
||
|
<a href='Guide_ArduinoXbeeShield?action=edit.html'>Edit Page</a> | <a href='Guide_ArduinoXbeeShield?action=diff.html'>Page History</a> | <a href='Guide_ArduinoXbeeShield?action=print.html' target='_blank'>Printable View</a> | <a href='http://arduino.cc/en/Site/AllRecentChanges'>All Recent Site Changes</a>
|
||
|
</div>
|
||
|
<!--/PageFooterFmt-->
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|