This library reads and interprets the NMEA strings from the GNSS receiver that is embedded in dice devices. It can be used for devices the include a receiver itself and also for devices that don’t have an embedded receiver.

In case of an embedded receiver this library:

  • auto. sets the embedded RTC
  • distributes the GPS data using the Datapool – library to the other devices on the CAN0 bus

Used by devices that do not bring a GNSS receiver, this library will:

  • attach to the Datapool that is distributed by GNSS capable devices on the CAN bus.
  • automatically set the embedded RTC

The library interface (methods and properties) can be used in the same way by the application no matter if the GNSS information comes from the embedded receiver or from a remote device (via datapool). The library will encapsulate the data handling for us in the background.

To use this library

#include "DICE_GPS.h"
void setup()
{
  GPS.begin();
}

By including the library, an object will be created that can be used for the following operations:

GPS

Example usage:

Serial.println("GPS data:");
Serial.println("- latitude: "+String(GPS.latitude()));
Serial.println("- longitude:"+String(GPS.longitude()));

Example

The following example can be compiled for any dice device since the library automatically detects if the target devices embeds a receiver or if it retrieved the GPS data from the data pool on the CAN bus.

#include "DICE_GPS.h"
void setup()
{
  while(!Serial);
  GPS.begin();	
}
void loop()
{
  Serial.println("GPS data:");
  Serial.println("-lat:  "+String(GPS.latitude()));
  Serial.println("-long: "+String(GPS.longitude()));
  Serial.println("-speed:"+String(GPS.speed()));
  Serial.println("-course:"+String(GPS.course()));
  Serial.println("-alt:  "+String(GPS.altitude()));
  Serial.println("-nbSats:"+String(GPS.satellites()));
  Serial.println("-Val:"+String(GPS.isPositionValid()));
  Serial.println("-time gps:"+String(GPS.getTime()));
  Serial.println("-time rtc: "+rtc.printTime();
  Serial.println("-date rtc: "+rtc.printDate());
  delay(2000);
  Serial.println(" ------------------ ");
}

DICE_GPSlibrary notes / compatibility

The library makes use of a Datapool object and also handles the serial data stream coming from the GPS receiver in the background. One can use the Datapool monitor to see the available data pool data on the bus (embedded in the CAN2SER monitor). It is also possible to make use of an externally connected 3rd party GPS receiver (e.g. by means of a dice-RS232). See the provided overloaded begin() function for more. Use isReceiverPresent() if your application likes to check first if there are positioning information to be expected at all.

Further information

dice users manual – details about device capabilities
Arduino_MKRGPS – Arduino Reference
RTC