Need help in coding for xbee with arduino, thanks.

Hi guys,

I am currently doing a project with pro mini and xbee series 1.

) Pro mini connect with different sensor (accelerometer, pressure sensor and GPS) and obtain data from these sensors
) Pro mini then gather these data and transmit to the xbee A(Transmitter)
) XBee A transmit the data to the XBee B (Receiver)
) XBee B is connect to the CPU and transmit data to the CPU for analysis.

My problem is what is the code for arduino to transmit the gathered data to the XBee? Where can i find the code?

Thanks a lot

My problem is what is the code for arduino to transmit the gathered data to the XBee?

You could add some servos, and attach semaphore flags to the servos. Have the Arduino wave the flags around, to send the message, by moving the servos.

Or, you could tell us how you have configured the XBees, and how they are attached to the Arduino. In general, replacing wires with XBees requires exactly ZERO changes to the code.

Thanks.

XBee (A) XBee(B)

CH-10 CH-10
ID-1992 ID-1992
DH-0 DH-0
DL-2643 DL-9796
MY-9796 MY-2643
SH-13A200 SH- 13A200
SL- 40B0B3C0 SL-40AA560F

http://www.nkcelectronics.com/UartSBee-V4-XBee-Explorer-USB_p_280.html
This is the adapter for the XBee

(XBee+Adapter) connect with arduino:

Adapter Arduino
GND GND
VCC 5V
RX TX
TX RX

http://cs.smith.edu/dftwiki/index.php/Tutorial:_Arduino_and_XBee_Communication

/*
Xbee1
D. Thiebaut

Makes Arduino send 1 character via XBee wireless to another XBee connected
to a computer via a USB cable.

The circuit:

  • RX is digital pin 2 (connect to TX of XBee)
  • TX is digital pin 3 (connect to RX of XBee)

Based on a sketch created back in the mists of time by Tom Igoe
itself based on Mikal Hart's example

*/

#include <SoftwareSerial.h>

SoftwareSerial xbee(2, 3); // RX, TX
char c = 'A';
int pingPong = 1;

void setup() {
Serial.begin(57600);
Serial.println( "Arduino started sending bytes via XBee" );

// set the data rate for the SoftwareSerial port
xbee.begin( 19200 );
}

void loop() {
// send character via XBee to other XBee connected to Mac
// via USB cable
xbee.print( c );

//--- display the character just sent on console ---
Serial.println( c );

//--- get the next letter in the alphabet, and reset to ---
//--- 'A' once we have reached 'Z'.
c = c + 1;
if ( c>'Z' )
c = 'A';

//--- switch LED on Arduino board every character sent---
if ( pingPong == 0 )
digitalWrite(13, LOW);
else
digitalWrite(13, HIGH);
pingPong = 1 - pingPong;
delay( 1000 );
}

The XBee with arduino can transmit alphabet to the XBee with CPU, but it doesn't always work.

Is this example related to what i wanna do, it is using AT mode, but i need the XBee to communicate in API mode?

Thanks a lot, sorry for any mistake.

I got the example work, the XBee connected with the Arduino can transmit characters to the XBee with CPU.

But what code do i need for:

Sensor--Arduino--XBee to XBee--CPU

Thanks a lotttttt.

I got the example work, ... But what code do i need for:

Did you get the example to work, or not? If so, then look at that code, to see how the Arduino talks to the XBee. From the way you describe your connections, talking to the PC from the Arduino is EXACTLY the same with wires or with XBees in place.