SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By adenong
#197127
Hi guys. I'm very new to arduino and xbee series 1. the main objective of my project is to able to control the lighting system from point A to point B using Xbee to transmit and receive. Right now i'm able to control the lighting from Xbee_A 'COM' by typing '1' as LED ON and '2' as LED OFF to the xbee_B. Furthermore, i would like to improvise the system by transferring data of the temperature values from point B back to point A. But i'm clueless on how to do that. Even after researching for days, i have no idea at all.

Xbee_A connected to shielding(https://www.cooking-hacks.com/communica ... xb-bt-rfid) to Arduino UNO
-jumper wire of DIN to pin 4, and DOUT to pin3

Xbee_B connection to shielding(https://www.cooking-hacks.com/communica ... xb-bt-rfid) to Arduino Mega
no jumper connection

TX CODE
Code: Select all
 #include<SoftwareSerial.h>
SoftwareSerial xbee(2,3);
char word1="";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  xbee.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0)//if key in something in COM
  {
    word1=Serial.read();//words equal what ou type
    xbee.println(word1);//xbee print out words
    Serial.print(word1);//
  }
  word1="";
RX CODE
Code: Select all
#include <dht.h>
#define DHT22_PIN A8 
int LED=13;
char letter;
dht DHT; //DHT 22 

float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);

}
void loop(){
  if(Serial.available()==0){
int chk = DHT.read22(DHT22_PIN);
  hum = DHT.humidity;
  temp= DHT.temperature;
    Serial.print("Humidity: ");
  Serial.print(hum);
  Serial.print(" %, Temp: ");
  Serial.print(temp);
  Serial.println(" Celsius");
  }
if(Serial.available() >0)
{
  letter = Serial.read();
  if(letter == '1')
  {
    //50% brightness manually from control station
    digitalWrite(LED, HIGH);
    
  }
  if (letter=='2')
  {
    digitalWrite(LED,LOW);
  }
}
}
Any kind soul able to help me out with this? I would really grateful if anyone can help me out.