Pages: [1]   Go Down
Author Topic: Arduino Leonardo and Xbee series 1 wireless communication  (Read 483 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello.

Could someone tell me how to receive data from XBee series 1 on Arduino Leonardo ?
I can receive any data from my xbee transmitter which is connected with a  potentiometer, and totally get lost... Any correction on my code would be sincerely appreciated.

My enviroments.
- Arduino Leonardo
- two XBee (Series 1)
- XBee shield from https://www.sparkfun.com/products/9976
- XBee Explorer Regulated https://www.sparkfun.com/products/11373?
- a potentiometer

two Xbees are well configured using X-CTU software (from digiKey) and has been tested without using leonardo. Right now I have my xbee receiver connected to leonardo through xbee shield. I would like to use a code to achieve voltage readout from my potentiometer which is connected with my xbee transimtter. Potentiometer voltage signal sends to DIO pin in xbee transmitter. 3.3V DC power is supplied to both Xbee trasmitter and potentiomter. And 3.3V pin and RES on my xbee transmitter has been wired together.

I followed the advice from this thread ( http://arduino.cc/forum/index.php/topic,114936.0.html). physically connect a 100uF capacitor (monolithic type, no polarity issue involved) the 3.3v pin and RES on my xbee receiver (which is what they call the shield's xbee) and run a IDE code looking like below:

Code:
void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
  while(!Serial){}; //required for the Leonardo
 
}

void loop() {
  while(Serial.available()>0){
    Serial1.write(Serial.read());// input from Serial to Serial1
  }
  while(Serial1.available()>0){
    Serial.write(Serial1.read()); //input from Serial1 to Serial
  }

  // read the input pin:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (3.3 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
     delay(1);
 }   

Let me know what I should do next. Thanks a lot.
« Last Edit: January 28, 2013, 08:18:12 pm by 33chen » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any suggestions on code or arrangement? Thanks.
Logged

Pages: [1]   Go Up
Jump to: