source: trunk/Arduino/GSM/testConnect/testConnect.ino@ 19225

Last change on this file since 19225 was 17968, checked in by ghughes, 10 years ago
Arduino Software Stuff
File size: 2.1 KB
Line 
1// import the GSM library
2#include <GSM.h>
3
4// PIN Number
5//#define PINNUMBER "0839"
6//#define PINNUMBER "7143"
7#define PINNUMBER "0060"
8
9// initialize the library instance
10GSM gsmAccess(true); // include a 'true' parameter for debug enabled
11//GSM gsmAccess(false); // include a 'true' parameter for debug enabled
12GSMScanner scannerNetworks;
13GSMModem modemTest;
14
15// Save data variables
16String IMEI = "";
17
18// serial monitor result messages
19String errortext = "ERROR";
20
21void setup()
22{
23 // initialize serial communications
24 Serial.begin(9600);
25 Serial.println("GSM networks scanner");
26 scannerNetworks.begin();
27
28 // connection state
29 boolean notConnected = true;
30
31 // Start GSM shield
32 // If your SIM has PIN, pass it as a parameter of begin() in quotes
33 while(notConnected)
34 {
35 if(gsmAccess.begin(PINNUMBER,true,true)==GSM_READY)
36 notConnected = false;
37 else
38 {
39 Serial.println("Not connected");
40 delay(1000);
41 }
42 }
43
44 // get modem parameters
45 // IMEI, modem unique identifier
46 Serial.print("Modem IMEI: ");
47 IMEI = modemTest.getIMEI();
48 IMEI.replace("\n","");
49 if(IMEI != NULL)
50 Serial.println(IMEI);
51
52 // currently connected carrier
53 Serial.print("Current carrier: ");
54 Serial.println(scannerNetworks.getCurrentCarrier());
55
56 // returns strength and ber
57 // signal strength in 0-31 scale. 31 means power > 51dBm
58 // BER is the Bit Error Rate. 0-7 scale. 99=not detectable
59 Serial.print("Signal Strength: ");
60 Serial.print(scannerNetworks.getSignalStrength());
61 Serial.println(" [0-31]");
62}
63
64void loop()
65{
66 // scan for existing networks, displays a list of networks
67 Serial.println("Scanning available networks. May take some seconds.");
68
69 Serial.println(scannerNetworks.readNetworks());
70
71 // currently connected carrier
72 Serial.print("Current carrier: ");
73 Serial.println(scannerNetworks.getCurrentCarrier());
74
75 // returns strength and ber
76 // signal strength in 0-31 scale. 31 means power > 51dBm
77 // BER is the Bit Error Rate. 0-7 scale. 99=not detectable
78 Serial.print("Signal Strength: ");
79 Serial.print(scannerNetworks.getSignalStrength());
80 Serial.println(" [0-31]");
81
82}
83
84
Note: See TracBrowser for help on using the repository browser.