obniz Parts Library


Usable Devices :
Found at :


Library for Grove GPS Module Grove - GPS.

<!-- HTML Example -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
<script src="https://unpkg.com/obniz@latest/obniz.js"></script>

<div id="obniz-debug"></div>
<h1>obniz GPS</h1>
<div id="obniz-gps"></div>

  var obniz = new Obniz("95496709");
  obniz.onconnect = async function () {
    let gps = obniz.wired("Grove_GPS", { rx: 0, tx: 1, vcc: 2, gnd: 3 });

    setInterval(async function () {
      let gpsInfo = gps.getGpsInfo();
      document.getElementById("obniz-gps").textContent = "longitude:" + gpsInfo.longitude + " latitude:" + gpsInfo.latitude;
    }, 1000);

wired(tx, rx {, vcc, gnd, grove})

Connect tx, rx, vcc, gnd to an obniz Board.

grove cable obniz Board
tx - rx
rx - tx
vcc - vcc
gnd - gnd

To prevent rush current, plase insert resistor(5~10R) between obniz vcc and GPS vcc.

And specify the pins on program.

// Javascript Example
let gps = obniz.wired("Grove_GPS", { rx:0, tx:1, vcc:2, gnd:3 });

If the device has a grove interface, it can be connected with just the parameter {grove: obniz.grove0}.

// Javascript Example
let gps = obniz.wired("Grove_GPS", {grove: obniz.grove0});

Functions are common with GYSFDMAXB Library apart from start1pps function.
The following is common functions.


Retriving infomation from received NMEA sentences.
Same information will be set to gpsInfo property.

editedData is optional.

// Javascript Example
let gps = obniz.wired("Grove_GPS", { rx:0, tx:1, vcc:2, gnd:3 });
let gpsInfo = getGpsInfo();


Read and analyze one sentence (one line) from received (NMEA Format).
Empty string will be returned when no data received.

This method is useful only when NMEA direct use.

One sentence will appear in one string.
Example: "$GPGGA,134214.000,3599.9999,N,13999.9999,E,2,11,0.97,57.4,M,39.5,M,,*5C"

// Javascript Example
let gps = obniz.wired("Grove_GPS", { rx:0, tx:1, vcc:2, gnd:3 });
let sentence = gps.readSentence();


Get GPS info object from received NMEA format.
Same data is set to editedData property.

  • editedData.enable : indicate having datas below
  • editedData.GPGGA : GPGGA sentence data
  • editedData.GPGLL : GPGLL sentence data
  • editedData.GPGSA : GPGSA sentence data
  • editedData.GPGSV[ ] : GPGSV array of sentence data
  • editedData.GPRMC : GPRMC sentence data
  • editedData.GPVTG : GPVTG sentence data
  • editedData.GPZDA : GPZDA sentence data
  • editedData.xxx : otherxxx sentence data
  • editedData.timestamp : GPZDA sentence data's date(Date object)

Example: $GPGGA,134214.000,3599.9999,N,13999.9999,E,2,11,0.97,57.4,M,39.5,M,,*5C


// Javascript Example
let gps = obniz.wired("Grove_GPS", { rx:0, tx:1, vcc:2, gnd:3 });

function mainLoop() {
  var data = gps.getEditedData();
  if (data.enable) {
    if (data.GPGGA)    console.log(data.GPGGA.join(","));
    if (data.GPGLL)    console.log(data.GPGLL.join(","));
    if (data.GPGSA)    console.log(data.GPGSA.join(","));
    if (data.GPGSV[0]) console.log(data.GPGSV[0].join(","));
    if (data.GPGSV[1]) console.log(data.GPGSV[1].join(","));
    if (data.GPGSV[2]) console.log(data.GPGSV[2].join(","));
    if (data.GPGSV[3]) console.log(data.GPGSV[3].join(","));
    if (data.GPRMC)    console.log(data.GPRMC.join(","));
    if (data.GPVTG)    console.log(data.GPVTG.join(","));
    if (data.GPZDA)    console.log(data.GPZDA.join(","));
    if (data.PMTK010)  console.log(data.PMTK010.join(","));
    if (data.PMTK011)  console.log(data.PMTK011.join(","));
  setTimeout(mainLoop, 100);

setTimeout(mainLoop, 10);

unit conversion methods

Data conversion methods for NMEA format.

  • nmea2dms(value)

    Latitude/Longitude of NMEA to DMS format string (999°99'99.9")

  • nmea2dm(value)

    Latitude/Longitude of NMEA to DM format string (999°99.9999')

  • nmea2dd(value)

    Latitude/Longitude of NMEA to DD format string (999.999999)

  • nmea2s(value)

    Latitude/Longitude of NMEA to S format string (0.999999999)

// Javascript Example
let gps = obniz.wired("Grove_GPS", { rx:0, tx:1, vcc:2, gnd:3 });
let d = gps.getEditedData();
if (d.enable) {
  if (d.GPGGA) {
    let p = d.GPGGA;
    if (p[6] !=="0") {
      let longitude = gps.nmea2dd(p[2]);
      let latitude = gps.nmea2dd(p[4]);


Supported from: obniz.js 3.5.0

You will Get in Few Days

Circuit for Starter “obniz Board” is available on Amazon and other online stores.
You can get it at below

Our products and resellers


Visit our developer’s forum to discuss and discover technologies.



Feel free to contact out support and technical team.

Contact us