Code examples and extended information
In the Waspmote Development section you can find complete examples:
1
#include <WaspXBeeDM.h>
2
#include <WaspFrame.h>
3
// Destination MAC address
4
//////////////////////////////////////////
5
char RX_ADDRESS[] = “0013A200402C02E3”;
6
//////////////////////////////////////////
7
// Define the Waspmote ID
8
char WASPMOTE_ID[] = “node_01”;
9
// define variable
10
uint8_t error;
11
void setup()
12
{
13
// init USB port
14
USB.ON();
15
USB.println(F(“Sending packets example”));
16
// store Waspmote identifier in EEPROM memory
17
frame.setID( WASPMOTE_ID );
18
}
19
// init XBee
20
xbeeDM.ON();
21
void loop()
22
{
23
///////////////////////////////////////////
24
// 1. Create ASCII frame
25
///////////////////////////////////////////
26
// create new frame
27
frame.createFrame(ASCII);
28
// add frame fields
29
frame.addSensor(SENSOR_STR, “new_sensor_frame”);
30
frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
31
///////////////////////////////////////////
32
// 2. Send packet
33
///////////////////////////////////////////
34
// send XBee packet
35
error = xbeeDM.send( RX_ADDRESS, frame.buffer, frame.length );
36
// check TX flag
37
if( error == 0 )
38
{
39
USB.println(F(“send ok”));
40
}
41
else
42
{
43
USB.println(F(“send error”));
44
}
45
// wait for five seconds
46
delay(5000);
47
}
Copied!
Last modified 1yr ago
Copy link