Kyneo GNSS positioning application

Introduction

GNSS stands for global navigation satellite system. GNSS units obtain their position from the estimated distances to the satellites in view. Once calculated, that information is transmitted to the system in a standard format known as NMEA frames (National Marine Electronics Association). There are some NMEA frames transmitting location information, but some others only include data concerning the number of satellites in view, the position of each of them and the whole constellation status, etc. So, in this tutorial, we will show how to obtain those NMEA frames as well as how to obtain the position and some additional info from them using Kyneo.

Simple GNSS program description

The GNSS module installed on Kyneo generated a máximum of 6 different NMEA frames. Three of them include position and/or altitude information, while the other three include data concerning Kyneo speed or information about the satellites on view. This means that a previous GNSS configuration has to be done in order to receive only those frames that are necessary for our particular application, as well as the frequency with which they are sent from the module to the micro controller.

 

Geko Navsat has developed a library specifically designed for all the GNSS uses so that is the first thing that must be included in our program. Right after that, we must declare our variables so that arduino knows how to deal with them.

In the setup process, the serials must be started, in this case, we must also start the serial port for the GNSS receiver and set it’s baud rate. Once that is complete, we will proceed to setup the NMEA frames as shown in the example program.

Finally, using the kyneo’s specific functions for day, hour, latitude, longitude and altitude, we can simply print the result of the calculation.

Example Sketch Code – GNSS Position

/**************************************************************************************************
 * Kyneo GNSS position Example.
 * 
 * This sketch will print the position measured by the kyneo board based in the GNSS sensor.
 * 
 * 
 * Created by GEKO Navsat S.L. for Kyneo V2.0 board
 * 
 * This example is free software, given under a GPL3 license
 * 
 * KYNEO is a product designed by GEKO Navsat S.L. in Europe http://www.gekonavsat.com
 * For further information, visit: http://kyneo.eu/
 * 
 *************************************************************************************************/
#include <KyneoBoard.h>                                 //GekoNavsat libraries
#include <KyneoGNSS.h>

KyneoGNSS gnss;                                         //Object definition

float lat, lon;                                         //Variable definition                                 
int alt;
char hour[10], day[10];

void setup()
{
  Serial.begin(9600);                                                              // Boards baudrate
  Serial1.begin(9600);                                                             // GNSS modules baudrate

  //set rate divider(GPGLL, GPRMC, GPVTG, GPGGA, GPGSA, GPGSV, PMTKCHN). 
  gnss.setNMEAOutput(    0,     1,     0,     1,     0,     0,       0);           //GPRMC 1Hz, GPGGA 1Hz
  
  Serial.println("Setup done\n");
}

void loop()
{
  if(gnss.getLatLon(lat, lon) == 2){                                               // Data adquisition
    gnss.getdate(day);
    gnss.gettime(hour);
    alt = gnss.getalt();
    
    Serial.println("--------------------");                                        //Data print
    Serial.print("Fecha:    ");
    Serial.println(day);
    Serial.print("Hora:     ");
    Serial.println(hour);
    Serial.print("Latitud:  ");
    Serial.println(lat,6);
    Serial.print("Longitud: ");
    Serial.println(lon,6);
    Serial.print("Altitud:  ");
    Serial.println(alt);
  }else{
    Serial.println("No GNSS information read...");
  }
}

GNSS bypass program description

Once understood how to get the NMEA frames out of a kyneo, lets see how we can configure the output of the GNSS sensor itself. For this, we need to make Kyneo read our instructions on the Serial monitor. So The following program will read from the computers serial and write on the GNSS chipsets one.

In order to configure the sensor, we will use the PMTK codes on the terminal. This will allow us to better control the output of the sensor and to play with features such as power saving modes or SBAS compatibility.

Example Sketch Code – GNSS Bypass

/**************************************************************************************************
 * Kyneo GNSS bypass Example.
 * 
 * This sketch will print the raw measured by the kyneo boards GNSS sensor, as well as accept PMTK 
 * commands for the GNSS sensor modification.
 * 
 * 
 * Created by GEKO Navsat S.L. for Kyneo V2.0 board
 * 
 * This example is free software, given under a GPL3 license
 * 
 * KYNEO is a product designed by GEKO Navsat S.L. in Europe http://www.gekonavsat.com
 * For further information, visit: http://kyneo.eu/
 * 
 *************************************************************************************************/
#include <KyneoBoard.h>                                                   //GekoNavsat libraries
#include <KyneoGNSS.h>

KyneoGNSS gnss;                                                           //Object definition

char c;                                                                   //Variable definition

void setup()
{
  Serial.begin(9600);                                                     // Boards baudrate
  Serial1.begin(9600);                                                    // GNSS modules baudrate

  //set rate divider(GPGLL, GPRMC, GPVTG, GPGGA, GPGSA, GPGSV, PMTKCHN). 
  gnss.setNMEAOutput(    0,     1,     5,     1,     0,     0,       0);  //GPRMC 1Hz, GPVTG 0.2Hz

  Serial.println("Setup done\n");
}

void loop()
{
  while(Serial1.available()){                                             //Serial1(GNSS) to Serial0 (USB)
    c = Serial1.read();
    Serial.print(c);
  }
  while(Serial.available()){                                              //Serial0 (USB) to Serial1(GNSS)
    c = Serial.read();
    Serial1.print(c);
  }
}

GNSS PPS program description

In order to make the correct calculations for the GNSS system to work, the clock time is crucial, that’s why GNSS satellites are equiped with atomic clocks, the most accurate ones on earth. For this reason, GNSS signal contents an extremely accurate time reading called PPS (Pulse Per Second), which can be used to have the exact time on the device, as well as to synchronise multiple devices.

In the following program we will use this extremely accurate data o blink and LED at the fixed rate of 1 second. In order to do this, we will read the GNSS_1PPS from our receiver and use that to make the LED blink.

Example Sketch Code – GNSS PPS

/**************************************************************************************************
 * Kyneo PPS signal Example.
 * 
 * This sketch will Light up a LED using the PPS signal obtained from the GNSS services
 * 
 * 
 * Created by GEKO Navsat S.L. for Kyneo V2.0 board
 * 
 * This example is free software, given under a GPL3 license
 * 
 * KYNEO is a product designed by GEKO Navsat S.L. in Europe http://www.gekonavsat.com
 * For further information, visit: http://kyneo.eu/
 * 
 *************************************************************************************************/
#include <KyneoBoard.h>                                 //GekoNavsat libraries

int LedTime = 100;  //milliseconds                      //Variable definition

void setup()
{
  Serial.begin(9600);                                   // Boards baudrate
  
  pinMode(GNSS_1PPS, INPUT);                            // Configure PPS signal pin as input
  pinMode(GP_LED_0, OUTPUT);                            // Configure LED0 as output
  
  Serial.println("Setup done\n");
}

void loop()
{
  if(digitalRead(GNSS_1PPS)){                           // Read PPS signal                      
    digitalWrite(GP_LED_0, HIGH);                      
    //Serial.println("LED ON!!");
    delay(LedTime);                              
    digitalWrite(GP_LED_0, LOW);
    //Serial.println("LED Off...");
  }
}

Link to software repository

Link to PMTK commands
Link to GNSS receiver datasheet
More information about Kyneo go to Kyneo Manual
For all the latest software visit our GitHub page GEKO Navsat Github's examples
Posted in Tutorials.