I am trying srnet's method of putting the GPS in the inactive state by sending the RXM-PMREQ message 0xB5, 0x62, 0x02, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4D, 0x3B so it can be hot fixed.
I bought the GPS breakout listed as a NEO-6M but I am unsure it is as listed. It has a XM37-1612 chip see image below (also attached).
I have been trying to find how to send the command/message to the GPS breakout, googling I found a guide on ublox power save modes:
https://ukhas.org.uk/guides:ublox_psm
It had a section on Turning the GPS to backup mode which i think is the same as inactive state? :
// Send a byte array of UBX protocol to the GPS
void sendUBX(uint8_t *MSG, uint8_t len) {
for(int i=0; i<len; i++) {
Serial.write(MSG[i]);
}
//Serial.println();
}
//Set GPS to backup mode (sets it to never wake up on its own)
uint8_t GPSoff[] = {0xB5, 0x62, 0x02, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4D, 0x3B};
sendUBX(GPSoff, sizeof(GPSoff)/sizeof(uint8_t));
delay(30000);
//Restart GPS
uint8_t GPSon[] = {0xB5, 0x62, 0x02, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x4C, 0x37};
sendUBX(GPSon, sizeof(GPSon)/sizeof(uint8_t));
I tried sending the message GPSoff but could see no change in the consumption?
I am using NeoGPS library to parse the GPS data (thanks to /dev). Is it still possible to send the commands to turn off/reduce the GPS module power while using the library?
Here is the sketch trying to reduce GPS power:
#include <NMEAGPS.h>
#define gpsPort Serial // pin 0 to GPS TX and pin 1 to GPS RX
NMEAGPS GPS;
gps_fix fix; // a structure that contains all the GPS pieces, like lat/lon
//============================ GPS power functions ================================//
// Send a byte array of UBX protocol to the GPS
void sendUBX(uint8_t *MSG, uint8_t len) {
for (int i = 0; i < len; i++) {
gpsPort.print(MSG[i]);
//Serial.write(MSG[i]);
}
Serial.println();
}
void GpsOff()
{
// ---- Set GPS to backup mode (sets it to never wake up on its own)
uint8_t GPSoff[] = {0xB5, 0x62, 0x02, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4D, 0x3B};
sendUBX(GPSoff, sizeof(GPSoff) / sizeof(uint8_t));
Serial.println(F("GPS power OFF"));
}
void GpsOn()
{
// ---- Restart GPS
uint8_t GPSon[] = {0xB5, 0x62, 0x02, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x4C, 0x37};
sendUBX(GPSon, sizeof(GPSon) / sizeof(uint8_t));
Serial.println(F("GPS power ON"));
}
//============================ Setup ======================================//
void setup() {
Serial.begin(9600);
Serial.println( F("NeoGPS library + GSM test!") );
// gpsPort.begin(9600);
GPS.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC+GGA
GPS.send_P( &gpsPort, F("PMTK220,1000") ); // 1Hz
GPS.send_P( &gpsPort, F("PGCMD,33,0") ); // No antenna status
delay(5000);
GpsOff();
delay(10000);
GpsOn();
}
//=============================== Loop ===================================//
void loop() {
// if a sentence is received...
if (GPS.available( gpsPort )) {
fix = GPS.read(); // get the latest pieces
readGPSdata();
}
}
//=============================== Functions ===============================//
void readGPSdata()
{
// if a sentence is received...
// if (GPS.available( gpsPort )) {
// fix = GPS.read(); // get the latest pieces
if (fix.valid.location) {
Serial.print( F("We have a fix!") );
} else
Serial.print( F("We dont have a fix!") );
Serial.print( F("\nLocation: ") );
if (fix.valid.location) {
Serial.print( fix.latitude(), 6);
Serial.print( F(", ") );
Serial.print( fix.longitude(), 6);
}
Serial.print( F("\nSatellites: ") );
if (fix.valid.satellites) {
Serial.print( fix.satellites );
}
Serial.print( F("\nFix: ") );
if (fix.valid.status) {
Serial.println(fix.status);
}
Serial.println();
}
Going back to the GPS module (XM37-1612 chip) I found a datasheet:
On page 13 it says to send message to put in standby mode so am unsure what will work?
unsigned char StandbyMode[] = {"$PMTK161,0*28\x0D\x0A"};
Thanks so much for any help, it's the very last stage of my project.
Ian.