We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Switching between arduino's over XBee
Page Index Toggle Pages: 1
Switching between arduino's over XBee (Read 338 times)
Switching between arduino's over XBee
Mar 12th, 2009, 5:29pm
 
I have 3 Xbee modules:
XBee1 connected to PC
XBee2 connected to sensor 1
XBee3 connected to sensor 2

I am currently reading data from sensor 1 to the PC using:

temprx = arduino.analogRead(temp); // Read data from temp sensor

Having set up ardunio using:

println(Arduino.list());  // List serial ports available to arduino
//Select serial port attached to arduino
arduino = new Arduino(this, Arduino.list()[1], 9600);

I now need to read the data from Sensor 2, so I had planned to configure XBee1 using:

void xset()
{
  println(Serial.list()); // List serial ports available
 // Select serial port connected to XBee
 port = new Serial(this, Serial.list()[1], 9600);
 int inByte = 0; // Declare variable called inByte
 port.write("+++"); // Put XBee into command mode
 delay(1100);  // Wait 1.1 sec
 // See if xbee replies
 while (inByte != '\r')
 {
   if (port.available() >0)
   {
     inByte = port.read();
     println (inByte);  // CHECK: XBee's reply
   }
 }
 port.write("ATDL5678\r"); // Set XBee destination address
 port.write("ATMY1234\r"); // Set XBee address
 port.write("ATWR\r"); // Save changes to XBee
 port.write("ATCN\r");  // Return XBee to data mode
 
}

I don't seem to be able to do this as the serial port is occupied from the previous:

println(Arduino.list());  // List serial ports available to arduino
//Select serial port attached to arduino
arduino = new Arduino(this, Arduino.list()[1], 9600);

Is there away to pause/stop this so I can access the serial port to carry out the configurtion.
Page Index Toggle Pages: 1