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