ZB 14: Set/Read Power Level
This program shows how to set and read the power mode at which the XBee module transmits at. Parameter Range: 0 - 4(default)

Required Materials

1 x Waspmote 1 x Battery 1 x MiniUSB wire 1 x XBee-ZigBee module

Notes

Parameter Range: 0 - 4(default)
XBee (S2) (boost mode enabled) 0 = -8 dBm 1 = -4 dBm 2 = -2 dBm 3 = 0 dBm 4 = +2 dBm ---------------------------------- XBee-PRO (S2) 4 = 17 dBm ---------------------------------- XBee-PRO (S2) - International variant - 4 = 17 dBm ---------------------------------- XBee-PRO (S2B) (boost mode enabled) 4 = 18 dBm 3 = 16 dBm 2 = 14 dBm 1 = 12 dBm 0 = 10 dBm ---------------------------------- XBee-PRO (S2B)- International variant - (boost mode enabled) 4 = 10 dBm 3 = 8 dBm 2 = 6 dBm 1 = 4 dBm 0 = 2 dBm ----------------------------------
REMARKS: Check your country's Restrictions
- The battery has to be connected. - This example can be executed in Waspmote v12

Code

1
/*
2
* ------ [ZB_14] - set/get the power level --------
3
*
4
* Explanation: This program shows how to set and read the power mode
5
* at which the XBee module transmits at. Parameter Range: 0 - 4(default)
6
*
7
* XBee (S2) (boost mode enabled)
8
* 0 = -8 dBm
9
* 1 = -4 dBm
10
* 2 = -2 dBm
11
* 3 = 0 dBm
12
* 4 = +2 dBm
13
* ----------------------------------
14
* XBee-PRO (S2)
15
* 4 = 17 dBm
16
* ----------------------------------
17
* XBee-PRO (S2) - International variant -
18
* 4 = 17 dBm
19
* ----------------------------------
20
* XBee-PRO (S2B) (boost mode enabled)
21
* 4 = 18 dBm
22
* 3 = 16 dBm
23
* 2 = 14 dBm
24
* 1 = 12 dBm
25
* 0 = 10 dBm
26
* ----------------------------------
27
* XBee-PRO (S2B)- International variant - (boost mode enabled)
28
* 4 = 10 dBm
29
* 3 = 8 dBm
30
* 2 = 6 dBm
31
* 1 = 4 dBm
32
* 0 = 2 dBm
33
* ----------------------------------
34
*
35
* REMARKS: Check your country's Restrictions
36
*
37
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
38
* http://www.libelium.com
39
*
40
* This program is free software: you can redistribute it and/or modify
41
* it under the terms of the GNU General Public License as published by
42
* the Free Software Foundation, either version 3 of the License, or
43
* (at your option) any later version.
44
*
45
* This program is distributed in the hope that it will be useful,
46
* but WITHOUT ANY WARRANTY; without even the implied warranty of
47
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48
* GNU General Public License for more details.
49
*
50
* You should have received a copy of the GNU General Public License
51
* along with this program. If not, see .
52
*
53
* Version: 0.2
54
* Design: David Gascón
55
* Implementation: Yuri Carmona
56
*/
57
58
#include <WaspXBeeZB.h>
59
60
// Define the power level value
61
////////////////////////////////////////////////
62
uint8_t powerValue=4;
63
////////////////////////////////////////////////
64
65
void setup()
66
{
67
// Init USB port
68
USB.ON();
69
USB.println(F("ZB_14 example\n"));
70
USB.println(F("----------------------------------"));
71
USB.println(F("\tPOWER LEVEL"));
72
USB.println(F("----------------------------------\n"
73
"XBee (S2) (boost mode enabled)\n"
74
"0 = -8 dBm\n"
75
"1 = -4 dBm\n"
76
"2 = -2 dBm\n"
77
"3 = 0 dBm\n"
78
"4 = +2 dBm\n"
79
"----------------------------------\n"
80
"XBee-PRO (S2)\n"
81
"4 = 17 dBm\n"
82
"----------------------------------\n"
83
"XBee-PRO (S2) - International variant -\n"
84
"4 = 17 dBm\n"
85
"----------------------------------\n"
86
"XBee-PRO (S2B) (boost mode enabled)\n"
87
"4 = 18 dBm\n"
88
"3 = 16 dBm\n"
89
"2 = 14 dBm\n"
90
"1 = 12 dBm\n"
91
"0 = 10 dBm\n"
92
"----------------------------------\n"
93
"XBee-PRO (S2B)- International variant - (boost mode enabled)\n"
94
"4 = 10 dBm\n"
95
"3 = 8 dBm\n"
96
"2 = 6 dBm\n"
97
"1 = 4 dBm\n"
98
"0 = 2 dBm\n"
99
"----------------------------------\n"
100
"XBee-PRO (S2C)\n"
101
"4 = 5 dBm\n"
102
"3 = 3 dBm\n"
103
"2 = 1 dBm\n"
104
"1 = -1 dBm\n"
105
"0 = -5 dBm\n"
106
"----------------------------------\n"
107
"XBee-PRO (S2D)\n"
108
"4 = 18 dBm\n"
109
"3 = 16 dBm\n"
110
"2 = 14 dBm\n"
111
"1 = 12 dBm\n"
112
"0 = 0 dBm\n"
113
"----------------------------------"));
114
115
delay(1000);
116
117
// init XBee
118
xbeeZB.ON();
119
120
// get the Power Level
121
xbeeZB.getPowerLevel();
122
123
USB.print(F("Current Power Level:"));
124
USB.println(xbeeZB.powerLevel, DEC);
125
USB.println();
126
delay(1000);
127
128
}
129
130
void loop()
131
{
132
133
// 1. set the Power Level to powerValue
134
USB.print(F("Set the Power Level to "));
135
USB.println(powerValue, DEC);
136
xbeeZB.setPowerLevel(powerValue);
137
138
139
// 2. get the Power Level
140
USB.print(F("Read the Power Level:"));
141
xbeeZB.getPowerLevel();
142
USB.println(xbeeZB.powerLevel, DEC);
143
USB.println();
144
delay(1000);
145
146
// 3. write actual value to module
147
USB.println(F("Write current value to module"));
148
xbeeZB.writeValues();
149
150
USB.println(F("******************************"));
151
delay(10000);
152
153
}
Copied!

Output

1
E#
2
ZB_14 example
3
4
----------------------------------
5
POWER LEVEL
6
----------------------------------
7
XBee (S2) (boost mode enabled)
8
0 = -8 dBm
9
1 = -4 dBm
10
2 = -2 dBm
11
3 = 0 dBm
12
4 = +2 dBm
13
----------------------------------
14
XBee-PRO (S2)
15
4 = 17 dBm
16
----------------------------------
17
XBee-PRO (S2) - International variant -
18
4 = 17 dBm
19
----------------------------------
20
XBee-PRO (S2B) (boost mode enabled)
21
4 = 18 dBm
22
3 = 16 dBm
23
2 = 14 dBm
24
1 = 12 dBm
25
0 = 10 dBm
26
----------------------------------
27
XBee-PRO (S2B)- International variant - (boost mode enabled)
28
4 = 10 dBm
29
3 = 8 dBm
30
2 = 6 dBm
31
1 = 4 dBm
32
0 = 2 dBm
33
----------------------------------
34
Current Power Level:4
35
36
Set the Power Level to 4
37
Read the Power Level:4
38
39
Write actual value to module
40
******************************
41
...
Copied!
Last modified 2yr ago