1 | /*
|
---|
2 | GPRS_Position
|
---|
3 |
|
---|
4 | A simple Sketch that shows the Longitude and Latitude
|
---|
5 | using a GSM shield.
|
---|
6 |
|
---|
7 | Circuit:
|
---|
8 | GSM shield attached
|
---|
9 |
|
---|
10 | Notes:
|
---|
11 | You have to change the apn, login and password.
|
---|
12 | If your SIM has PIN you have to set
|
---|
13 |
|
---|
14 | created 3 Apr. 2015
|
---|
15 | by Arduino.org team (http://arduino.org)
|
---|
16 | */
|
---|
17 |
|
---|
18 | // Library include
|
---|
19 | #include <GSM.h>
|
---|
20 | // SIM and Network constant
|
---|
21 | #define PINNUMBER "" // if present, insert Your PIN here
|
---|
22 | #define apn "internet.wind" // change the apn
|
---|
23 | //#define apn "ibox.tim.it"
|
---|
24 | //#define apn "unico.tim.it"
|
---|
25 | //#define apn "wap.tim"
|
---|
26 | #define login "" // insert your login
|
---|
27 | #define password "" // isnert your password
|
---|
28 |
|
---|
29 | // initialize the library instance
|
---|
30 | GSM gsmAccess; // GSM access: include a 'true' parameter for debug enabled
|
---|
31 | GPRS gprsAccess; // GPRS access
|
---|
32 | GSMClient client; // Client service for TCP connection
|
---|
33 | GSM2 gprsPosition; // GPRS Posistioning system
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 | void setup() {
|
---|
38 | // put your setup code here, to run once:
|
---|
39 | Serial.begin(9600);
|
---|
40 |
|
---|
41 | // start GSM shield
|
---|
42 |
|
---|
43 | Serial.println(" ");
|
---|
44 | Serial.print("Connecting GSM network...");
|
---|
45 | if (gsmAccess.begin(PINNUMBER) != GSM_READY)
|
---|
46 | {
|
---|
47 | Serial.println("Error !");
|
---|
48 | while (true);
|
---|
49 | }
|
---|
50 | Serial.println("Ok !");
|
---|
51 | Serial.println("Setting APN...");
|
---|
52 | gprsAccess.attachGPRS(apn, login, password);
|
---|
53 | Serial.print("APN :");
|
---|
54 | Serial.println(apn);
|
---|
55 | Serial.print("Login :");
|
---|
56 | Serial.println(login);
|
---|
57 | Serial.print("Password :");
|
---|
58 | Serial.println(password);
|
---|
59 | }
|
---|
60 |
|
---|
61 | void loop() {
|
---|
62 | // put your main code here, to run repeatedly:
|
---|
63 |
|
---|
64 | Serial.print("Position: ");
|
---|
65 | Serial.println(gprsPosition.getPosition());
|
---|
66 |
|
---|
67 | }
|
---|