7
7
basically do whatever you want with this code.
8
8
9
9
This example shows how to query a Ublox module for the current time and date. We also
10
- turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
10
+ turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
11
11
dramatically.
12
12
13
13
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
@@ -33,63 +33,63 @@ long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox m
33
33
34
34
void setup ()
35
35
{
36
- Serial.begin (115200 );
37
- while (!Serial)
38
- ; // Wait for user to open terminal
39
- Serial.println (" SparkFun Ublox Example" );
40
-
41
- Wire.begin ();
42
-
43
- if (myGPS.begin () == false ) // Connect to the Ublox module using Wire port
44
- {
45
- Serial.println (F (" Ublox GPS not detected at default I2C address. Please check wiring. Freezing." ));
46
- while (1 )
47
- ;
48
- }
49
-
50
- myGPS.setI2COutput (COM_TYPE_UBX); // Set the I2C port to output UBX only (turn off NMEA noise)
51
- myGPS.saveConfiguration (); // Save the current settings to flash and BBR
36
+ Serial.begin (115200 );
37
+ while (!Serial)
38
+ ; // Wait for user to open terminal
39
+ Serial.println (" SparkFun Ublox Example" );
40
+
41
+ Wire.begin ();
42
+
43
+ if (myGPS.begin () == false ) // Connect to the Ublox module using Wire port
44
+ {
45
+ Serial.println (F (" Ublox GPS not detected at default I2C address. Please check wiring. Freezing." ));
46
+ while (1 )
47
+ ;
48
+ }
49
+
50
+ myGPS.setI2COutput (COM_TYPE_UBX); // Set the I2C port to output UBX only (turn off NMEA noise)
51
+ myGPS.saveConfiguration (); // Save the current settings to flash and BBR
52
52
}
53
53
54
54
void loop ()
55
55
{
56
- // Query module only every second. Doing it more often will just cause I2C traffic.
57
- // The module only responds when a new position is available
58
- if (millis () - lastTime > 1000 )
59
- {
60
- lastTime = millis (); // Update the timer
61
-
62
- long latitude = myGPS.getLatitude ();
63
- Serial.print (F (" Lat: " ));
64
- Serial.print (latitude);
65
-
66
- long longitude = myGPS.getLongitude ();
67
- Serial.print (F (" Long: " ));
68
- Serial.print (longitude);
69
- Serial.print (F (" (degrees * 10^-7)" ));
70
-
71
- long altitude = myGPS.getAltitude ();
72
- Serial.print (F (" Alt: " ));
73
- Serial.print (altitude);
74
- Serial.print (F (" (mm)" ));
75
-
76
- byte SIV = myGPS.getSIV ();
77
- Serial.print (F (" SIV: " ));
78
- Serial.print (SIV);
79
-
80
- Serial.println ();
81
- Serial.print (myGPS.getYear ());
82
- Serial.print (" -" );
83
- Serial.print (myGPS.getMonth ());
84
- Serial.print (" -" );
85
- Serial.print (myGPS.getDay ());
86
- Serial.print (" " );
87
- Serial.print (myGPS.getHour ());
88
- Serial.print (" :" );
89
- Serial.print (myGPS.getMinute ());
90
- Serial.print (" :" );
91
- Serial.println (myGPS.getSecond ());
92
-
93
- Serial.println ();
94
- }
56
+ // Query module only every second. Doing it more often will just cause I2C traffic.
57
+ // The module only responds when a new position is available
58
+ if (millis () - lastTime > 1000 )
59
+ {
60
+ lastTime = millis (); // Update the timer
61
+
62
+ long latitude = myGPS.getLatitude ();
63
+ Serial.print (F (" Lat: " ));
64
+ Serial.print (latitude);
65
+
66
+ long longitude = myGPS.getLongitude ();
67
+ Serial.print (F (" Long: " ));
68
+ Serial.print (longitude);
69
+ Serial.print (F (" (degrees * 10^-7)" ));
70
+
71
+ long altitude = myGPS.getAltitude ();
72
+ Serial.print (F (" Alt: " ));
73
+ Serial.print (altitude);
74
+ Serial.print (F (" (mm)" ));
75
+
76
+ byte SIV = myGPS.getSIV ();
77
+ Serial.print (F (" SIV: " ));
78
+ Serial.print (SIV);
79
+
80
+ Serial.println ();
81
+ Serial.print (myGPS.getYear ());
82
+ Serial.print (" -" );
83
+ Serial.print (myGPS.getMonth ());
84
+ Serial.print (" -" );
85
+ Serial.print (myGPS.getDay ());
86
+ Serial.print (" " );
87
+ Serial.print (myGPS.getHour ());
88
+ Serial.print (" :" );
89
+ Serial.print (myGPS.getMinute ());
90
+ Serial.print (" :" );
91
+ Serial.println (myGPS.getSecond ());
92
+
93
+ Serial.println ();
94
+ }
95
95
}
0 commit comments