Sending command to Grove GPS module

I am using a Grove GPS module in combination with the arduino MKR NB1500. I use the UART interface (RX/TX).

I am trying to put the GPS module into sleep mode, which is possible according to the datasheet.

However, i am unable to succesfully send the command to the GPS sensor. I tried gpsSerial.print and gpsSerial.write, both not working. My code is shown below:

#include "TinyGPS++.h"
TinyGPSPlus gps;

#define gpsSerial Serial1

unsigned long currentTime;
unsigned long lastDisplayTime = 0;
unsigned long test = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  gpsSerial.begin(9600);
  delay(3000);
  
}

void loop() {
  // put your main code here, to run repeatedly:
  currentTime = millis();
  
  // Constantly feed gps values
  while ( gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
  }

  if (currentTime - lastDisplayTime >= 500) {
    Serial.print("Sats:"); Serial.print(gps.satellites.value()); Serial.print(", ");
    Serial.print("Lat:"); Serial.print(gps.location.lat(), 6); Serial.print(", ");
    Serial.print("Lon:"); Serial.print(gps.location.lng(), 6); Serial.print(", ");
    Serial.print("Time:"); Serial.println(gps.time.value());
    lastDisplayTime = currentTime;
  }

  if (currentTime > 10000 && test == 0){
    Serial.println("Put into standby mode");
    gpsSerial.write("PMTK225,2,3000,12000,18000,72000");
    gpsSerial.print("PMTK225,2,3000,12000,18000,72000");
    test = 1;
  }
}

Anyone knows the correct sentence to send a command to my GPS module?

Are you sure that the command sequence should be a string ?

Please post a link to the GPS manual

1 Like

Good point! I am not sure if it should be a string. I also can't find an answer to that in the datasheet.

Here the link of the GPS datasheet
https://files.seeedstudio.com/wiki/Grove-GPS/res/SIM28_DATA_File.zip

I did manage to send a different command with succes which puts the GPS in low power mode.
Working code:

#include "TinyGPS++.h"
TinyGPSPlus gps;

#define gpsSerial Serial1

unsigned long currentTime;
unsigned long lastDisplayTime = 0;
unsigned long test = 0;
unsigned long test1 = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  gpsSerial.begin(9600);
  delay(3000);

}

void loop() {
  // put your main code here, to run repeatedly:
  currentTime = millis();

  // Constantly feed gps values
  while ( gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
  }

  if (currentTime - lastDisplayTime >= 500) {
    Serial.print("Sats:"); Serial.print(gps.satellites.value()); Serial.print(", ");
    Serial.print("Lat:"); Serial.print(gps.location.lat(), 6); Serial.print(", ");
    Serial.print("Lon:"); Serial.print(gps.location.lng(), 6); Serial.print(", ");
    Serial.print("Time:"); Serial.println(gps.time.value());
    lastDisplayTime = currentTime;
  }

  if (currentTime > 10000 && test == 0) {
    Serial.println("Put into standby mode");
    gpsSerial.println("$PMTK161,0*28<CR><LF>");
    delay(500);
    test = 1;
  }

  if (currentTime > 90000 && test1 == 0) {
    Serial.println("Put GPS on:");
    gpsSerial.println("$PMTK161,1*28<CR><LF>");
    delay(500);
    test1 = 1;
  }
}

Although this command works I still have no idea why the first command didn't work. If someone knows i am curious to know :smiley:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.