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:
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?
How can I send a message to X&Y and set a digital output to high (both configured to same pin)?
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.
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);
}