Code examples and extended information

In the Waspmote Development section you can find complete examples:

Example:

#include <WaspXBee802.h>
#include <WaspFrame.h>
// Destination MAC address
//////////////////////////////////////////
char RX_ADDRESS[] = “0013A200406E5DC5”;
//////////////////////////////////////////
// Define the Waspmote ID
char WASPMOTE_ID[] = “node_01”;
// define variable
uint8_t error;
void setup()
{
// init USB port
USB.ON();
USB.println(F(“Sending packets example”));
// store Waspmote identifier in EEPROM memory
frame.setID( WASPMOTE_ID );
}
// init XBee
xbee802.ON();
void loop()
{
///////////////////////////////////////////
// 1. Create ASCII frame
///////////////////////////////////////////
// create new frame
frame.createFrame(ASCII);
// add frame fields
frame.addSensor(SENSOR_STR, “new_sensor_frame”);
frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
///////////////////////////////////////////
// 2. Send packet
///////////////////////////////////////////
// send XBee packet
error = xbee802.send( RX_ADDRESS, frame.buffer, frame.length );
// check TX flag
if( error == 0 )
{
USB.println(F(“send ok”));
}
else
{
USB.println(F(“send error”));
}
// wait for five seconds
delay(5000);
}