Go Down

Topic: Fio v3 Xbee <> Arduino Uno Xbee  (Read 147 times) previous topic - next topic

msolomos

Hello,

This is probably a newbie question but I would like your help as I have been strugling for over a week. I am trying to send a 0/1 from a Fio over an Xbee S1 to an Arduino Uno with a Xbee shield to turn on LED 13.

Ofcourse I have already setup xbee's and I have double check that they communicate to each other.

I managed to make it work with USB explorer connected to my PC and coolterm. When I type 0, led is off and when I type 1, led is ON.

Here is the code I am using to UNO side:

Code: [Select]

int incomingByte = 0; // for incoming serial data
 
void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  pinMode(13, OUTPUT);
 
  // blink twice at startup
  digitalWrite(13, LOW);
  delay(1000);
 
  digitalWrite(13, HIGH); // first blink
  delay(50);
  digitalWrite(13, LOW);
  delay(200);
  digitalWrite(13, HIGH); // second blink
  delay(50);
  digitalWrite(13, LOW);
}
 
void loop() {
  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();
 
    if(incomingByte == '0'){
      digitalWrite(13, LOW);
    }else if(incomingByte == '1'){
      digitalWrite(13, HIGH);
    }   
    // say what you got:
    Serial.print("UNO received: ");
    Serial.write(incomingByte);  // Arduino 1.0 compatibility
    Serial.write(10);    // send a line feed/new line, ascii 10
  }
}


I tried to take it a step further. I wanted to achieve the same thing from a Fio v3 (it has a Xbee socket) using the serial monitor.

here is the code at Fio's side am using but nothing happens

Code: [Select]

#include <SoftwareSerial.h>

SoftwareSerial xBee = SoftwareSerial(2,3);

void setup() {

  Serial.begin(9600);
  xBee.begin(9600);
  Serial.println("Sending...");
}

// the loop routine runs over and over again forever:

void loop() {

  xBee.print(1);
  delay(1000);        // delay in between reads for stability
  xBee.print(0);
}





Please forgive me but I don't know where to start from. What is missing? What am doing wrong?
Any help or guidance would be much apreciated.

thanks in advance

msolomos

#1
Oct 31, 2014, 11:55 am Last Edit: Oct 31, 2014, 11:57 am by msolomos
I could never imagine that serial1.print will make such a big diference!!
Here is the small code that works : - )


Code: [Select]

void setup() {

  Serial1.begin(9600);

}


void loop() {

  Serial1.println(1);
  delay(1000);        // delay in between reads for stability
  Serial1.println(0);

}




Am very happy because this time I found the solution myself :- )

However I did try to reverse the code just to experiment. From Uno > Fio.

There is no serial1 on Uno. How to send the character via xbee to Fio?

Go Up