pradeep_k_b
Full Member level 3
- Joined
- Dec 21, 2011
- Messages
- 160
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,306
- Location
- Nilambur, India
- Activity points
- 2,509
Hi all,I am trying to design a mesh network using Xbee s2 and arduinos.In the first stage I am trying to create communication between two arduinos using Xbee s2,I am using the AT mode.I have programmed the arduino as follows
sender:
Receiver
:
I am using Arduino UNO and MEGA,And configured Xbees using XCTU.I am connecting Xbees directly to the Arduions(without any shield,I have two boards with MAX232 to configure the Xbees and also I am powering Xbee through this board because there is some inbuilt 3.3V regulator) and connected TX of Xbee directly to Arduino RX and Arduino TX connected to Xbee RX through a voltage divider.
In the STEP-1 I connected arduinos using wires UNO TX to MEGA RX and UNO Rx to MEGA Tx and its
working fine.
In the STEP-2 I replaced the wired connection with Xbees but its not working
Then in STEP-3 I replaced the sender Arduino with my laptop( I used XCTU) and its working perfect without any problem.When I type 1 in terminal box the LED turned ON on and a 0 turned OFF the LED
I am attaching the YouTube video link of the 3 steps(something that I captured with my camera)
https://www.youtube.com/watch?v=4lz_BMZ3AY4&feature=youtu.be
https://www.youtube.com/watch?v=rLVNddzoLF0&feature=youtu.be
https://www.youtube.com/watch?v=6B_GzSBNvas&feature=youtu.be
Please help me solve this problem,I am working on this for the past couple of days,watched a lot of tutorial videos,read a lot and tried different methods but I couldn't solve this...
sender:
Code:
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("1"); //turn on the LED
delay(1000);
Serial.println("0");//turn off the LED
delay(1000);
}
Receiver
Code:
int ledPin = 13; // use the built in LED on pin 13 of the Uno
int state = 0;
int flag = 0; // make sure that you return the state only once
void setup() {
// sets the pins as outputs:
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(9600); // Default connection rate for my BT module
}
void loop() {
//if some data is sent, read it and save it in the state variable
if(Serial.available() > 0){
state = Serial.read();
flag=0;
}
// if the state is 0 the led will turn off
if (state == '0') {
digitalWrite(ledPin, LOW);
if(flag == 0){
Serial.println("LED: off");
flag = 1;
}
}
// if the state is 1 the led will turn on
else if (state == '1') {
digitalWrite(ledPin, HIGH);
if(flag == 0){
Serial.println("LED: on");
flag = 1;
}
}
}
I am using Arduino UNO and MEGA,And configured Xbees using XCTU.I am connecting Xbees directly to the Arduions(without any shield,I have two boards with MAX232 to configure the Xbees and also I am powering Xbee through this board because there is some inbuilt 3.3V regulator) and connected TX of Xbee directly to Arduino RX and Arduino TX connected to Xbee RX through a voltage divider.
In the STEP-1 I connected arduinos using wires UNO TX to MEGA RX and UNO Rx to MEGA Tx and its
working fine.
In the STEP-2 I replaced the wired connection with Xbees but its not working
Then in STEP-3 I replaced the sender Arduino with my laptop( I used XCTU) and its working perfect without any problem.When I type 1 in terminal box the LED turned ON on and a 0 turned OFF the LED
I am attaching the YouTube video link of the 3 steps(something that I captured with my camera)
https://www.youtube.com/watch?v=4lz_BMZ3AY4&feature=youtu.be
https://www.youtube.com/watch?v=rLVNddzoLF0&feature=youtu.be
https://www.youtube.com/watch?v=6B_GzSBNvas&feature=youtu.be
Please help me solve this problem,I am working on this for the past couple of days,watched a lot of tutorial videos,read a lot and tried different methods but I couldn't solve this...