Code examples and extended information

In the Waspmote Development section you can find complete examples:

http://www.libelium.com/development/waspmote/examples

Example:

#include <WaspXBee900HP.h>
#include <WaspFrame.h>
// Destination MAC address
//////////////////////////////////////////
char RX_ADDRESS[] =0013A20040A63E21”;
//////////////////////////////////////////
// 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
 xbee900HP.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());

 // show frame to send
 frame.showFrame();
 ///////////////////////////////////////////
 // 2. Send packet
 ///////////////////////////////////////////
 // send XBee packet
 error = xbee900HP.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);
}

Last updated