Xbee send to all / switch digi-out on

Hello all,

I have a question regarding XBee API library.

I have following network:
• Mainboard Ardurino Mega w/ XBee S2 API mode
• Station 1) Ardurino Leonardo w/ XBee S2 API mode
• Station 2) Ardurino Fio w/ XBee S2 API mode
• Station X) Sparkfun Explorer Board w/ XBee S2 AT mode
• Station Y) Sparkfun Explorer Board w/ XBee S2 AT mode

The Mainboard is receiving data from all Stations (payload from S1&2, Digital Status from X&Y).

Now at one point in time in my Mainboard program I would like to send an information to all devices. They need to switch an LED to ON.

OK, due to the fact I have two in API and two in AT - I think I have to send two messages?

So my two questions where google didn’t tells me an answer:

  1. How can I send a message with payload to both API devices (Station 1&2). The message is the same. So I don’t want to send same massages two times to talk specific device. I would like to do it with one message which both can receive. Is that possible?
  2. How can I send a message to X&Y and set a digital output to high (both configured to same pin)?

Thanks Christoph

So I don't want to send same massages two times to talk specific device.

Why not? That seems like the most obvious solution.

To safe program code and time... is it not possible with libary?

I can't find in internet how to switch the i/o output of xbee on. Any ideas?

Thanks
Christoph

I can't find in internet how to switch the i/o output of xbee on. Any ideas?

Pins need to be configured as input or output first, using X-CTU.

Then, when the XBee sends a packet with data that the receiver knows is relevant to an OUTPUT pin, it will apply the data to the appropriate output pin. The Arduino does not need to do anything to make that happen.

Maybe my writing was a bit misleading… Sorry for that, I’m not native English speaker.

I have an Arudrino Leonardo w/ XBee S2 set to API coordinator and would like to send to another XBee in AT mode to switch LED at I/O 3 to HIGH.

How can I do it with XBee.h library?

and would like to send to another XBee in AT mode to switch LED at I/O 3 to HIGH.

You can't. If you want the XBee to understand "set pin 3 HIGH", you MUST use API mode, and set the appropriate bit in the package.

How can I do it with XBee.h library?

Andrew Rapp wrote a great book, "Wireless Sensor Networks". For anyone doing stuff with XBees, this book is a must have.

PaulS:
You can't.

With Xbee libary or in general?

Would like to do this: https://www.youtube.com/watch?v=CzH146rR-7I with xbee libary.

With Xbee libary or in general?

The XBee library assumes that you are using API mode.

Ok... though there is a possibility because it can receive AT packs.

What about broadcast/ speak to all? Does that work with the libary or do I nead to programm it the old fashion way?

What about broadcast/ speak to all? Does that work with the libary

You define the address of the XBee you want to send to. If you want to send to all, use the broadcast address.

For all who would like to send a Command to an AT XBee... IT IS POSSIBLE WITH THE LIBARY!

Here an Example which switch an LED at XBee Output D3 on and off. It works perfect:

#include <XBee.h>

XBee xbee = XBee();

// Turn on I/O sampling
uint8_t irCmd[] = {'D','3'};
// What to do 4 = output low; 5 = output high
uint8_t irValue[] = {0x04};

// SH + SL of your remote radio
XBeeAddress64 remoteAddress = XBeeAddress64(0x0013a200, 0x400a3e02);
// Create a remote AT request with the IR command
RemoteAtCommandRequest remoteAtRequest = RemoteAtCommandRequest(0xc2bb, irCmd, irValue, sizeof(irValue));

void setup() {
  Serial1.begin(9600);
  xbee.setSerial(Serial1);
  // Use Serial for printing to the serial monitor
  Serial.begin(9600);
  // wait for leonardo Serial
  while (!Serial);
  delay(4000);
  Serial.println("XBee sketch is running!");
}
 
void loop() {
  irValue[0] = 5;
  sendRemoteAtCommand();
  delay(2000);
  irValue[0] = 4;
  sendRemoteAtCommand();
  delay(2000);
}

void sendRemoteAtCommand() {
  Serial.println("Sending command to the XBee");
 
  // send the command
  xbee.send(remoteAtRequest);
}