background image

Step 8: Sending Serial Data 

When using the ZNet 2.5 firmware, routers or end devices will communicate with the 
coordinator by default. This makes point to point communication really easy. All you need to do 
is send serial data to the XBee router connected to the Arduino and it will be received by the 
coordinator where you can read it into your computer. 
 
Connect the Arduino with the XBee Shield to your computer using a USB cable. The jumpers on 
the XBee shield should still be disconnected. Load the following sketch on to the Arduino. 
 

 
/*  Serial Test code 
    Sends "testing..." over the serial connection once per second 
    while blinking the LED on pin 13. Used for testing serial devices 
    such as the XBee. 
     
    Adapted from the SoftSerial Demonstration code 
*/ 
 
#define ledPin 13 
byte pinState = 0; 
 
void setup()  { 
  pinMode(ledPin, OUTPUT); 
  Serial.begin(9600); 

 
void loop() { 
  
  Serial.println("testing..."); 
  // toggle an LED just so you see the thing's alive.  
  toggle(13); 
  delay(1000); 
 

 
void toggle(int pinNum) { 
  // set the LED pin using the pinState variable: 
  digitalWrite(pinNum, pinState); 
  // if pinState = 0, set it to 1, and vice versa: 
  pinState = !pinState; 

 

 
 
Once the sketch is loaded, unplug the Arduino and connect the 
“XBEE/USB” jumpers on the XBee Shield to the XBee side of 
the headers (see the photo to the right). Power the Arduino again 
and wait for the “Associate” LED to begin blinking again and the 
sketch to start. 
 

Содержание ZNet 2 Series

Страница 1: ...ncluded with NKC kit 1 Male Header row for XBee breakout Sparkfun SKU PRT 00117 or included with NKC kit 1 FT232RL Breakout Board Sparkfun SKU BOB 00718 male or female headers for the FT232RL Breakout...

Страница 2: ...circuit on your bread board using the diagram Instead of using a reset switch I just plug one end of a jumper wire into the XBee reset pin and leave the other end of that jumper hanging off the edge...

Страница 3: ...nected to the XBee should light up and stay on assuming your XBee shipped as a Router End Device and there is no Coordinator around to connect to Download the X CTU software from Digi and install it T...

Страница 4: ...ent settings of the attached XBee Select ZNet 2 5 Router End Device AT as the firmware in the pull down menu Change the Node Identifier to something like router1 You may want to change the PAN ID to a...

Страница 5: ...for Coordinator Type ATID to check the PAN Network ID that the XBee is using It should respond with 123 or whatever unique PAN ID you set in step 4 Type ATNI to check the Node Identifier The XBee sho...

Страница 6: ...m the settings in the terminal and move on to the next step Step 7 Creating the network At this point you should have one XBee updated with the ZNet 2 5 Router firmware plugged into the XBee Shield on...

Страница 7: ...the serial connection once per second while blinking the LED on pin 13 Used for testing serial devices such as the XBee Adapted from the SoftSerial Demonstration code define ledPin 13 byte pinState 0...

Страница 8: ...wo XBee modules and you want two routers end devices to talk to one another you ll need to set the Destination Nodes for each module You can easily do this by entering command mode typing and then sen...

Отзывы: