Skip to content

Commit 6417815

Browse files
committed
Add example to get location
1 parent ae1a8ac commit 6417815

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Diff for: examples/GetLocation/GetLocation.ino

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "ArduinoCellular.h"
2+
3+
ArduinoCellular cellular = ArduinoCellular();
4+
5+
void setup(){
6+
Serial.begin(115200);
7+
while (!Serial);
8+
cellular.setDebugStream(Serial);
9+
cellular.begin();
10+
11+
if(!cellular.enableGPS()){
12+
Serial.println("Failed to enable GPS");
13+
while(true); // Stop the program
14+
}
15+
delay(2000); // Give the modem some time to initialize
16+
}
17+
18+
void loop(){
19+
Location location = cellular.getGPSLocation();
20+
Serial.println("GPS Location:");
21+
Serial.print("* Latitude: "); Serial.println(location.latitude, 6);
22+
Serial.print("* Longitude: "); Serial.println(location.longitude, 6);
23+
Serial.println("--------------------\n");
24+
delay(10000);
25+
}

0 commit comments

Comments
 (0)