Hi i'm developing a WSN where every end device before starting transmitting must receive a call from the Coordinator. For testing purpose I'm working with 4 Arduino nano 3.0 (in the final configuration i will use a different microcontroller with an M3 cortex cpu) and four XBee (xb24-b with zb firmware). I am not able to send a message from the coordinator to the selected end device, meanwhile i successfully accomplish to transmit data from end device to the coordinator. here the code running on the arduino on the coordinator node. The end device is directly connect to the pc with an USB explorer.
#include <SoftwareSerial.h>
// creo una porta seriale di tipo software sui pin 2(RX) e 3(TX)
uint8_t rxxbee = 2;
uint8_t txxbee = 3;
SoftwareSerial Serial_xbee(rxxbee,txxbee);
// variable to store the data received
int sensorValue = 0;
// costant values of the frame
const byte startDelimeter = 0x7E;
// length
const byte MSB_1 = 0x00;
const byte LSB_2 = 0x10;
// Frame-specific data
const byte frameType = 0x10;
const byte frameID = 0x0;
// 64-bit destination address
const byte MSB_5 = 0x00;
const byte b_6 = 0x13;
const byte b_7 = 0xA2;
const byte b_8 = 0x00;
const byte b_9 = 0x40;
const byte b_10 = 0x86;
const byte b_11 = 0xDB;
const byte LSB_12 = 0xA4;
// 16-bit destination network address
const byte MSB_13 = 0x0;
const byte LSB_14 = 0x0;
// broadcast radius
const byte broadcastRadius = 0x0;
// options
const byte opt = 0x0;
byte spedisci (byte value) {
Serial_xbee.write(value);
Serial.write(value);
return value;
}
void setup()
{
// starts serial communication
Serial.begin(9600);
Serial_xbee.begin(9600);
pinMode(sensorPin, INPUT);
}
void loop()
{
// send data through xBee
spedisci(startDelimeter);
spedisci(MSB_1);
spedisci(LSB_2);
long sum = 0; // accumulate the checksum
sum += spedisci(frameType);
sum += spedisci(frameID);
sum += spedisci(MSB_5);
sum += spedisci(b_6);
sum += spedisci(b_7);
sum += spedisci(b_8);
sum += spedisci(b_9);
sum += spedisci(b_10);
sum += spedisci(b_11);
sum += spedisci(LSB_12);
sum += spedisci(MSB_13);
sum += spedisci(LSB_14);
sum += spedisci(broadcastRadius);
sum += spedisci(opt);
sum += spedisci(0X10); // this is the payload[0] byte
sum += spedisci(0X10); // this is the payload[1] byte
spedisci( 0xFF - (sum & 0xFF));
}
Any suggestion?
thanks!
Ps the coordinator api firmware is 21A7; the end device api firmware is 29A7