XBee Communication Arduino

hi everyone,
how to code to communicate XBee using arduino?
and xbee configuration in xctu like this

  1. For ROUTER
    ...
    pp
    ;;;

  2. FOR COOR
    i did the same for the configuration in the coordination, the different only in CE (Coordinator Enable) for the coordinator Enable

Previously I have created a program like this

  1. for receive
#include <SoftwareSerial.h>
SoftwareSerial xbee(2,3);

String perintah_string;
String perintah;

void setup() {
  Serial.begin(9600);
  xbee.begin(9600);
}

void loop() {
    while(xbee.available()>0){
    char perintah_char = xbee.read();    
    perintah_string += perintah_char;
    perintah_string.trim();

    if(perintah_string.length()>0){      
      
      perintah = perintah_string;
      Serial.print(perintah);
      Serial.print(perintah_string);

      perintah = "";
      perintah_string = "";
    }
   }
}
  1. for transmitter
#include<SoftwareSerial.h>
SoftwareSerial xbee(2,3);

void setup()
{
    Serial.begin(9600);
    xbee.begin(9600);
}

void loop()
{
  xbee.write("HELLO");
  Serial.println("HELLO");
}

and I made the wiring
RX (xbee) to TX (arduino)
TX (xbee) to RX (arduino)
gnd (xbee) to gnd (arduino)
3v (xbee) to 3.3v (arduino)
[/quote]

i made the same wiring on both xbee

RX (xbee) to 2 (arduino)
TX (xbee) to 3 (arduino)
gnd (xbee) to gnd (arduino)
3v (xbee) to 3.3v (arduino)

this is the wire i actually made on both of xbee

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for advice on (nor for problems with) your project.

Please do not post screenshots of code or errors. Post them using so-called code tags.

thanks for replying, I've fixed it

Thanks. Makes it easiet to tead and copy. I'm not familiar with XBee so can't help.

ok thanks, its ok

What model of Arduino are you using, an Uno or something else?

Is the Xbee plugged into some kind of interface board or shield?

What model of Xbee model do you have and what firmware is loaded. (There are many different hardware versions and a bewildering array of firmware choices.)

Just looking at the code for the transmitter, you are sending data as fast as possible however the Xbee is probably incapable of handling data at that high rate, so you will get data corruption. Perhaps start by only sending one message per second.

thanks for replying.
i use arduino uno for both,

yes, I use xbee usb adapter, and what I use is xbee pro s3b for both, for firmware I made it on XBP9B-DM and function set XBee PRO 900HP 200K and firmware 8075.

actually I tried to send 1 message per second, but nothing happened, so I thought the delay was too long and I deleted the delay.

actually if i put the xbee transmitter on the usb adapter and the xbee receiver through the arduino uno, i can already send any message,
but the problem is i haven't found any code to transmit "hello world" message if both xbees communicate using arduino uno, i have tried many programs and no result, would you help me?

In 'point to point' transparent mode you can probably set both devices to CE = End Device [0], as there is no concept of a coordinator (or router) in a point to point connection.

Make sure the Xbee's have different values for MY and DL.
If one has DL = 1 and MY = 2, the other must be DL = 2 and MY = 1.

Simplify the receiver loop code so that it simply prints each character as it arrives. First get basic communication working.

I have changed the configuration as you mentioned, and here is my latest code:

  1. Receiver
#include <SoftwareSerial.h>
SoftwareSerial xbee(2,3);

String perintah_string;

void setup() {
  Serial.begin(9600);
  xbee.begin(9600);
}

void loop() {
    while(xbee.available()>0){
    char perintah_char = xbee.read();    
    perintah_string += perintah_char;
    perintah_string.trim();      
      Serial.print(perintah_string);
      perintah_string = "";
   }
}
  1. Transmitter
#include<SoftwareSerial.h>
SoftwareSerial xbee(2,3);

void setup()
{
    Serial.begin(9600);
    xbee.begin(9600);
}

void loop()
{
  xbee.write("HELLO");
  Serial.println("HELLO");
  delay(1000);
}

but no result yet :sleepy:

Digi is the company that makes the Xbee, so perhaps post your problem to the Digi forum
https://forums.digi.com/.

okee thanks for info

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.