Note: this page refers to a product that is retired.

Band Management

Manage the band the GSM shield connects to.

This example is part of the tools supplied to manage the GSM shield and shows how to use the GSM Library to manage the GSM band the modem connects to.

Check http://www.worldtimezone.com/gsm.html for general GSM band information. Typical regional configurations are:

  • Europe, Africa, Middle East: E-GSM(900)+DCS(1800)

  • USA, Canada, South America: GSM(850)+PCS(1900)

  • Mexico: PCS(1900)

  • Brazil: GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)

Hardware Required

Circuit

image of the Arduino GSM Shield on top of an Arduino board
image of the Arduino GSM Shield on top of an Arduino board

Code

1This sketch, for the Arduino GSM shield, checks the band currently configured in the modem and allows you to change
2it.
1/*
2
3 Band Management
4
5 This sketch, for the Arduino GSM shield, checks the band
6
7 currently configured in the modem and allows you to change
8
9 it.
10
11 Please check http://www.worldtimezone.com/gsm.html
12
13 Usual configurations:
14
15 Europe, Africa, Middle East: E-GSM(900)+DCS(1800)
16
17 USA, Canada, South America: GSM(850)+PCS(1900)
18
19 Mexico: PCS(1900)
20
21 Brazil: GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)
22
23 Circuit:
24
25 * GSM shield
26
27 created 12 June 2012
28
29 by Javier Zorzano, Scott Fitzgerald
30
31 This example is in the public domain.
32
33 */
34
35// libraries
36#include <GSM.h>
37
38// initialize the library instance
39
40GSMBand band;
41
42void setup() {
43
44 // initialize serial communications and wait for port to open:
45
46 Serial.begin(9600);
47
48 while (!Serial) {
49
50 ; // wait for serial port to connect. Needed for Leonardo only
51
52 }
53
54 // Beginning the band manager restarts the modem
55
56 Serial.println("Restarting modem...");
57
58 band.begin();
59
60 Serial.println("Modem restarted.");
61
62};
63
64void loop() {
65
66 // Get current band
67
68 String bandName = band.getBand(); // Get and print band name
69
70 Serial.print("Current band:");
71
72 Serial.println(bandName);
73
74 Serial.println("Want to change the band you're on?");
75
76 String newBandName;
77
78 newBandName = askUser();
79
80 // Tell the user what we are about to do...
81
82 Serial.print("\nConfiguring band ");
83
84 Serial.println(newBandName);
85
86 // Change the band
87
88 bool operationSuccess;
89
90 operationSuccess = band.setBand(newBandName);
91
92 // Tell the user if the operation was OK
93
94 if (operationSuccess) {
95
96 Serial.println("Success");
97
98 } else {
99
100 Serial.println("Error while changing band");
101
102 }
103
104 if (operationSuccess) {
105
106 while (true);
107
108 }
109}
110
111// This function offers the user different options
112// through the Serial interface
113// The user selects one
114
115String askUser() {
116
117 String newBand;
118
119 Serial.println("Select band:");
120
121 // Print the different options
122
123 Serial.println("1 : E-GSM(900)");
124
125 Serial.println("2 : DCS(1800)");
126
127 Serial.println("3 : PCS(1900)");
128
129 Serial.println("4 : E-GSM(900)+DCS(1800) ex: Europe");
130
131 Serial.println("5 : GSM(850)+PCS(1900) Ex: USA, South Am.");
132
133 Serial.println("6 : GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)");
134
135 // Empty the incoming buffer
136
137 while (Serial.available()) {
138
139 Serial.read();
140
141 }
142
143 // Wait for an answer, just look at the first character
144
145 while (!Serial.available());
146
147 char c = Serial.read();
148
149 if (c == '1') {
150
151 newBand = GSM_MODE_EGSM;
152
153 } else if (c == '2') {
154
155 newBand = GSM_MODE_DCS;
156
157 } else if (c == '3') {
158
159 newBand = GSM_MODE_PCS;
160
161 } else if (c == '4') {
162
163 newBand = GSM_MODE_EGSM_DCS;
164
165 } else if (c == '5') {
166
167 newBand = GSM_MODE_GSM850_PCS;
168
169 } else if (c == '6') {
170
171 newBand = GSM_MODE_GSM850_EGSM_DCS_PCS;
172
173 } else {
174
175 newBand = "GSM_MODE_UNDEFINED";
176
177 }
178
179 return newBand;
180}

Last revision 2018/08/23 by SM

Suggest changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. If you see anything wrong, you can edit this page here.

License

The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.