Hi guys!
How are you? I've came here to ask if someone knows how to send data, like a message using xbee's (end device and coordinator) in mode API???? I need that part of the code please. Im using a 6 digital temperature sensor's in a one-wire protocol (1 wire, several sensors attached) connected to arduino+xbee shield+xbee and, i want to send this temperatures to another xbee connected to a PC using mode API with the program X-CTU. The part that i have working in mode AT of xbee and it worked is this:
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// Arduino 1-Wire Address Finder
DeviceAddress sensor1 = { 0x28, 0x18, 0x4F, 0x24, 0x03, 0x00, 0x00, 0xF8 };
DeviceAddress sensor2 = { 0x28, 0x34, 0x51, 0x24, 0x03, 0x00, 0x00, 0xED };
DeviceAddress sensor3 = { 0x28, 0x22, 0x84, 0x24, 0x03, 0x00, 0x00, 0x88 };
DeviceAddress sensor4 = { 0x28, 0x2A, 0x78, 0x24, 0x03, 0x00, 0x00, 0xAE };
DeviceAddress sensor5 = { 0x28, 0x01, 0x4F, 0x24, 0x03, 0x00, 0x00, 0x35 };
DeviceAddress sensor6 = { 0x28, 0x4F, 0x88, 0x24, 0x03, 0x00, 0x00, 0x20 };
int myData = 3;
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(sensor1, 10);
sensors.setResolution(sensor2, 10);
sensors.setResolution(sensor3, 10);
sensors.setResolution(sensor4, 10);
sensors.setResolution(sensor5, 10);
sensors.setResolution(sensor6, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print("C: ");
Serial.print(tempC);
}
}
void loop(void)
{
delay(2000);
sensors.requestTemperatures();
printTemperature(sensor1);
printTemperature(sensor2);
printTemperature(sensor3);
printTemperature(sensor4);
printTemperature(sensor5);
printTemperature(sensor6);
}
Thank you