TX code:
#include <SoftwareSerial.h>
const int MAX_LENGTH = 2;
char buffer[MAX_LENGTH];
char lineFeed = 2;
SoftwareSerial Xbee(10, 11);
void setup() {
Serial.begin(9600);
Xbee.begin(9600);
}
void loop() {
int length = Serial.readBytesUntil(lineFeed, buffer, MAX_LENGTH);
int i = 0;
while( i < length )
{
Serial.print(buffer[i]-48);
Xbee.print(buffer[i]-48);
i++;
}
}
RX code:
const int MAX_LENGTH = 2;
char buffer[MAX_LENGTH];
char lineFeed = 2;
void setup() {
Serial.begin(9600);
}
void loop() {
int length = Serial.readBytesUntil(lineFeed, buffer, MAX_LENGTH);
int i = 0;
while( i < length )
{
Serial.print(buffer[i]-48);
i++;
}
}
NOTE :
1- The Rx xbee is receiving data even if am not sending and even if the TX xbee is powered off
2- When i send data from the TX xbee id didn't get revived by the RX xbee
I need to solve both problems.
*** What i need exactly is to send serial data from my pc to arduino and send it wireless through xbee and then receive to the other arduino connected to my circuit