One Arduino transmitter + One Arduino receiver

I have configured two Maxstream Xbees with the X-CTU software.

I'm using two Maxstream Xbee Pro. (series 1) Ardunio Duemilanove (Atmega168)

Now i want to send something simple from Ardunio transmitter to the Ardunio receiver.

I do not know how to write the program to transmit and also another program to receive.

Can some1help? Thank you very muuuuchhh :D

I connect microcontroller+ shield+Xbee together(for both Ardunio). Then USB to two respective computers for each Ardunio.

Anything that appears on the TX pin gets sent over-the-air by the XBee. Anything that the XBee receives is put on the RX pin.

The Serial.print(), Serial.write(), and Serial.println() are how the Arduino puts data on the TX pin.

The Serial.read() function is how the Arduino gets data from the RX pin.

do u have any sample program that i can try out? Thanks :)

void setup() { Serial.begin(57600); }

void loop() { Serial.println("hello"); delay(1000); }

The program above puts data on the Tx pin. If i want to receive the data on another Ardunio (i.e. transmit the string data wirelessly), and show it on its serial monitor....how should my receiver program be like? Can some1help? :)...thankssss :)

I think you have to use 2 serial ports. 1 for the communication with the Xbee, and 1 to show the data what's received by the receiving Arduino on the serial port at the computer.

Maybe you can use SoftSerial for one of those 2...

Good luck!

Atmoz

I think you have to use 2 serial ports.

No. The XBee doesn’t bind to the serial port, so the PC, Arduino, and XBee can all communicate.

If you want to keep the Arduino <–> XBee and Arduino <–> PC communications separate, then you would need to use NewSoftSerial for one channel.

i don’t quite wad u r saying…sorry…i m bad at this…is my transmitter problem above correct?

i connect microcontroller+Xbee+shield together…den USB to computer…

configured the modem with X-CTU software already

The code you showed in Reply #3 should work fine. That Arduino will send "hello" to the serial port once a second. The PC attached to the USB connect AND the XBee will see the data. The PC will show the value in the Serial Monitor, if it is open, and the XBee will broadcast it.

Somewhere you need to have a receiver. That receiver will have code like this on it:

void loop()
{
   while(Serial.available() > 0)
   {
      Serial.print(Serial.read());
   }
}

Anything that arrives on the serial port, because the XBee received it over-the-air will be read by the Arduino. The Serial.print() statement will cause the data to be seen by the PC AND sent over-the-air by the XBee.

As you can see, you could get into an infinite loop sending the same data back and forth. As soon as you know that this is happening, you need to add distinguishing IDs to the messages, so the Arduino that receives the data knows whether it is its own message being echoed back, or a message originating from somewhere else.

ok i understand....thanks for the very clear explanation...I will test it on monday..will get back to this thread asap...

appreciate your prompt reply all the time!!! :) :) :)

Hey peeps, i was wondering if there is a command that gets data on the RX pin(Serial.read()) and show it on the serial monitor without sending out any data?

i know that Serial.println () writes data to the serial port. I don't want that. I just want to receive whatever data that is transmitted from another arduino and show it on the serial monitor.

Can that be done? :-?

The Serial Monitor forms the other send of the serial port. Use Serial.print(), Serial.println(), or Serial.write() to send data to it.

If i use the command Serial.println() at the Ardunio that is receiving the data(receiver end), will i be sending the data that i have received back to the transmitter? Or the Serial.println command will just display what i have received from the transmitter onto the serial monitor?

Cause i don't want the receiver to send the data back to the transmitter---------only the transmitter send, receiver reads and show it sent on serial monitor :)

If i use the command Serial.println() at the Ardunio that is receiving the data(receiver end), will i be sending the data that i have received back to the transmitter? Or the Serial.println command will just display what i have received from the transmitter onto the serial monitor?

Cause i don't want the receiver to send the data back to the transmitter

The Serial.print(ln) command will send both.

Once you know that the XBees are sending and receiving, you don't need to see what they are sending on the serial monitor.

oh ok i understand...ya u r right...i don't need to use serial monitor after knowing wad i have been receiving at the receiver end.. :)

Thanks guys...i m finally able to transmit a string message wirelessly from one Arduino to another Arduino.

I have a doubt though.

My transmitter program is as follows.

void setup( ) { Serial.begin (9600); } void loop( ) { float voltage = 0; int sensorValue = analogRead (A0); voltage = sensorValue * 0.0048; // code width(sensitivity) = 5 / 210 = 4.8mV Serial.println (voltage, DEC); delay (1000); }

At the receiver end, i did not even write any program. All i did was open serial monitor with the same baud rate. I m able to get the data that i want. (i.e. receive whatever that is transmitted).

I already configured the two Xbees with the X-CTU software.

I don't understand but it seems like its correct. Can some1 explain wad is happening? Thanks!!! :)

i m finally able to transmit a string message wirelessly from one Arduino to another Arduino.

:)

At the receiver end, i did not even write any program. All i did was open serial monitor with the same baud rate. I m able to get the data that i want. (i.e. receive whatever that is transmitted).

I already configured the two Xbees with the X-CTU software.

I don't understand but it seems like its correct. Can some1 explain wad is happening?

The Serial Monitor is one end of the serial connection. The Arduino with XBee is at the other end. Either the Arduino OR the XBee can put data on the serial port pins on that end.

The Serial Monitor simply reads the data on the port, without knowing (or caring) which device on the other end put the data there.

If the Arduino connected to the PC is supposed to do something with the data, too, it will need some code to read the serial data, too.

hello :slight_smile:

it occured to me that these two threads should be linked together. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1289089043/30 The hardware and software is different, but the desired outcome is essentially the same. when I looked for a wireless system to check out, it seemed like a toss-up between xbee and nordic. I ultimately went with nordic, nudged along by a totorial by fritzing, and their promise of ultra-cheep modules (which I then didn’t invest in… hm.)

-mike :slight_smile: