1
+ /*
2
+ Register your LTE Shield/SIM combo on a mobile network operator
3
+ By: Jim Lindblom
4
+ SparkFun Electronics
5
+ Date: October 23, 2018
6
+ License: This code is public domain but you buy me a beer if you use this
7
+ and we meet someday (Beerware license).
8
+ Feel like supporting our work? Buy a board from SparkFun!
9
+ https://www.sparkfun.com/products/14997
10
+
11
+ This example demonstrates how to initialize your Cat M1/NB-IoT shield, and
12
+ connect it to a mobile network operator (Verizon, AT&T, T-Mobile, etc.).
13
+
14
+ Before beginning, you may need to adjust the mobile network operator (MNO)
15
+ setting on line 83. See comments above that line to help select either
16
+ Verizon, T-Mobile, AT&T or others.
17
+
18
+ Hardware Connections:
19
+ Attach the SparkFun LTE Cat M1/NB-IoT Shield to your Arduino
20
+ Power the shield with your Arduino -- ensure the PWR_SEL switch is in
21
+ the "ARDUINO" position.
22
+ */
23
+
24
+ // Click here to get the library: http://librarymanager/All#SparkFun_LTE_Shield_Arduino_Library
1
25
#include < SparkFun_LTE_Shield_Arduino_Library.h>
2
26
27
+ // We need to pass a Serial or SoftwareSerial object to the LTE Shield
28
+ // library. Below creates a SoftwareSerial object on the standard LTE
29
+ // Shield RX/TX pins:
30
+ // Note: if you're using an Arduino board with a dedicated hardware
31
+ // serial port, comment out the line below. (Also see note in setup.)
3
32
SoftwareSerial lteSerial (8 , 9 );
33
+
34
+ // Create a LTE_Shield object to be used throughout the sketch:
4
35
LTE_Shield lte;
5
36
6
37
// Map registration status messages to more readable strings
7
38
String registrationString[] = {
8
- " Not registered" , // 0
9
- " Registered, home" , // 1
10
- " Searching for operator" , // 2
11
- " Registration denied" , // 3
12
- " Registration unknown" , // 4
13
- " Registrered, roaming" , // 5
14
- " Registered, home (SMS only)" , // 6
15
- " Registered, roaming (SMS only)" , // 7
16
- " Registered, home, CSFB not preferred" , // 8
17
- " Registered, roaming, CSFB not prefered" // 9
39
+ " Not registered" , // 0
40
+ " Registered, home" , // 1
41
+ " Searching for operator" , // 2
42
+ " Registration denied" , // 3
43
+ " Registration unknown" , // 4
44
+ " Registrered, roaming" , // 5
45
+ " Registered, home (SMS only)" , // 6
46
+ " Registered, roaming (SMS only)" , // 7
47
+ " Registered, home, CSFB not preferred" , // 8
48
+ " Registered, roaming, CSFB not prefered" // 9
18
49
};
19
50
20
51
void setup () {
21
- Serial.begin (9600 );
52
+ Serial.begin (9600 );
22
53
23
- Serial.println (F (" Initializing the LTE Shield..." ));
24
- Serial.println (F (" ...this may take ~25 seconds if the shield is off." ));
25
- Serial.println (F (" ...it may take ~5 seconds if it just turned on." ));
54
+ Serial.println (F (" Initializing the LTE Shield..." ));
55
+ Serial.println (F (" ...this may take ~25 seconds if the shield is off." ));
56
+ Serial.println (F (" ...it may take ~5 seconds if it just turned on." ));
26
57
27
- if ( lte.begin (lteSerial, 9600 ) ) {
58
+ // Call lte.begin and pass it your Serial/SoftwareSerial object to
59
+ // communicate with the LTE Shield.
60
+ // Note: If you're using an Arduino with a dedicated hardware serial
61
+ // poert, you may instead slide "Serial" into this begin call.
62
+ if ( lte.begin (lteSerial) ) {
28
63
Serial.println (F (" LTE Shield connected!" ));
64
+ } else {
65
+ Serial.println (F (" Unable to communicate with the shield." ));
66
+ Serial.println (F (" Manually power-on (hold POWER for 3 seconds) on and try again." ));
67
+ while (1 ) ; // Loop forever on fail
29
68
}
30
69
Serial.println ();
31
70
@@ -46,8 +85,8 @@ void setup() {
46
85
// MNO_TELSTRA -- Telstra
47
86
// MNO_TMO -- T-Mobile
48
87
if (!lte.setNetwork (MNO_VERIZON)) {
49
- Serial.println (F (" Error setting network. Try cycling power on your Arduino/shield." ));
50
- while (1 ) ;
88
+ Serial.println (F (" Error setting network. Try cycling power on your Arduino/shield." ));
89
+ while (1 ) ;
51
90
}
52
91
53
92
Serial.println (" Network set. Ready to go!" );
@@ -59,9 +98,10 @@ void setup() {
59
98
Serial.println (" Network registration: " + registrationString[regStatus]);
60
99
}
61
100
if (regStatus > 0 ) {
62
- Serial.println (" All set. Go to the next example!" );
101
+ Serial.println (" All set. Go to the next example!" );
63
102
}
64
103
}
65
104
66
105
void loop () {
106
+ // Do nothing. Now that we're registered move on to the next example.
67
107
}
0 commit comments