Go Down

Topic: GPS module power management (Read 3527 times) previous topic - next topic

itmoto

#30
Nov 19, 2017, 07:44 pm Last Edit: Nov 20, 2017, 12:23 am by itmoto
Thanks srnet, I have just read on the ublox forum there are plenty of fakes out there.
Will have to take care to buy a genuine one if the XM37-1612 standby mode message doesn't work.

----------

Thanks /dev, I will try that message and will see what happens.

The datasheet says sending any byte will wake the GPS module from standby and will return the message {"$PMTK010,002*2D\x0D\x0A"} and start normal operation.
Hopefully NeoGPS will ignore that sentence if it's received as well.

-dev

Quote
Hopefully NeoGPS will ignore that sentence if it's received as well.
Yes.  NeoGPS only parses sentences that you have enabled in NMEAGPS_cfg.h:

Code: [Select]
#define NMEAGPS_PARSE_GGA
#define NMEAGPS_PARSE_GLL
#define NMEAGPS_PARSE_GSA
#define NMEAGPS_PARSE_GSV
#define NMEAGPS_PARSE_GST
#define NMEAGPS_PARSE_RMC
#define NMEAGPS_PARSE_VTG
#define NMEAGPS_PARSE_ZDA

If the sentence isn't one you can enable, NeoGPS will always ignore it.
Really, I used to be /dev.  :(

itmoto

I tried this code to send the message:

Code: [Select]
#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


//============================ 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
 
  Serial.println();
  delay(5000);

  GPS.send_P( &gpsPort, F("PMTK161,0") );
 
  Serial.println();
  delay(5000);

  GPS.send_P( &gpsPort, F("P") ); // send byte to wake up module
 
  //GPS module will return {"$PMTK010,002*2D\x0D\x0A"} and start normal operation.
}

//=============================== 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();
}


Does this look correct?

Im not getting any reduction in current  :smiley-sad:

This is the output from the serial monitor:

NeoGPS library + GSM test!
$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28
$PMTK220,1000*1F
$PGCMD,33,0*6D

$PMTK161,0*28

$P*50



I have also tried connecting directly to the GPS from the FTDI. The TX from FTDI flashes when I send the message.

I tried sending:

$PMTK161,0*28\x0D\x0A
$PMTK161,0

Still no joy.

-dev

I assume that the Arduino TX pin 1 is connected to the GPS RX pin.  Otherwise, the GPS device will never receive a command.  If it is connected properly, this code might be the problem:

Quote
GPS.send_P( &gpsPort, F("PMTK161,0") );
  
  Serial.println();  <-- this probably cancels the standby command
  delay(5000);

  GPS.send_P( &gpsPort, F("P") ); // send byte to wake up module
It looks like you are sending bytes immediately after the standby command.  Anything you send to Serial is sent to gpsPort.  They are the same port.

You do not need the extra println, because send_P already sent the CR/LF required by the NMEA standard.  It may be waking the device immediately.
Really, I used to be /dev.  :(

itmoto

#34
Nov 21, 2017, 11:27 pm Last Edit: Dec 01, 2017, 11:14 am by itmoto
Yes, the 328p TX is connected to GPS RX.

Something strange though, on the FTDI, (after I uploaded the code) Im sure I didn't see the TX LED flash when closing and opening the serial monitor at the point the message was sent to the GPS module, which is why I connected the module directly to the FTDI.
When sent the message it did flash the TX but still didn't change the consumption.

I actually tried it without the Serial.println(); (I think) but it still didn't work.

I added the println after to clearly separate the messages, didn't realise that could be enough to wake the module though. 

I will remove and retry without the println to confirm.

From snippets I found online (where you have helped others) I didn't realise the GPS.send_p setup commands were for the MTK platform to select the RMC & GGA the HZ rate and the antenna status.

I even changed the rate message from F("PMTK220,1000") ); 1HZ to F("PMTK220,10000") ); 10HZ to see if there was any change. It seemed to stay at the same rate.

Thanks /dev

-dev

Quote
I even changed the rate message from F("PMTK220,1000") ); 1HZ to F("PMTK220,10000") ); 10HZ
That would change the interval to 0.1Hz, or one update every 10 seconds.  The PMTK220 parameter is the number of milliseconds between updates (period, not frequency).
Really, I used to be /dev.  :(

itmoto

Yes, sorry it is the interval of position fix, this is what i meant to put  $PMTK220,100*2F<CR><LF> 10HZ (I just wanted to try anything to see if messages were getting through)

I just tried it without the Serial.println and just sent the message once in setup() and Loop() was empty as below:

Code: [Select]

#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


//============================ 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

  GPS.send_P( &gpsPort, F("PMTK161,0") );    // change GPS to standby mode
}

//=============================== 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();
}

Still no change.

Am I actually sending the message correctly?

This is the output from serial monitor, it seems the checksums have been added:

Quote
NeoGPS library + GSM test!
$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28
$PMTK220,1000*1F
$PGCMD,33,0*6D
$PMTK161,0*28
Is there any other message you can think of that I could send to test if the module is receiving messages?

If not I will get another module and maybe use a mosfet for this one.

itmoto

Update...

I just found out I was sending the correct command after all to enter standby mode but the problem was I failed to leave any delay after sending each command.

I added a delay after each command and now it enters standby mode successfully and the consumption has reduced from 22mA to 1mA!

For anyone that may find it useful, here is the code, for sending (MTK Platform (MediaTek Inc.)) commands that reduce the GPS current, it also uses the NeoGPS library to parse GPS data.
After 10 seconds in standby mode it wakes then outputs location if has a fix.

Code: [Select]
#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


//============================ Setup ======================================//

void setup() {

  Serial.begin(9600);
  Serial.println( F("NeoGPS library & current reduction 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
  delay(50);
  GPS.send_P( &gpsPort, F("PMTK220,1000") ); // 1Hz
  delay(50);
  GPS.send_P( &gpsPort, F("PGCMD,33,0") );   // No antenna status
  delay(5000);                               // wait 5 seconds before standby mode

  Serial.println( F("") );
  Serial.println( F("In GPS standby mode for 10 seconds...") );
  GPS.send_P( &gpsPort, F("PMTK161,0") );    // send standby mode command to GPS (current = 1.02MA)

  delay(10000);
  Serial.println( F("") );

  //GPS.send_P( &gpsPort, F("P") );          // wake module send a byte (current = 21.9MA)
  Serial.println( F("GPS awake now...") );   // or will wake on Serial.print
  Serial.println( F("") );
}

//=============================== Loop ===================================//

void loop() {

  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();
  }
}


Has anyone managed to reduce the current lower than 1mA by sending commands to one of these modules?

srnet

I just found out I was sending the correct command after all to enter standby mode but the problem was I failed to leave any delay after sending each command.
I would suggest the failure is not a lack of delay but that your software does not check that the command sent has been correctly acknowledged.
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

itmoto

#39
Dec 05, 2017, 12:10 pm Last Edit: Dec 06, 2017, 09:22 am by itmoto
I would suggest the failure is not a lack of delay but that your software does not check that the command sent has been correctly acknowledged.
How would you check that the command has been correctly acknowledged?
The datasheet doesn't say it returns anything after sending the standby command?

It does say "Issue any byte to wake up GPS module, the GPS module will return {"$PMTK010,002*2D\x0D\x0A"}and start normal operation."

It also says "User can issue software command to make GPS module go into standby mode that consumes less than 200uA current."

I am measuring 1mA in standby mode. Do you think the regulator is using the 800uA?

srnet

I am measuring 1mA in standby mode. Do you think the regulator is using the 800uA?
No idea.

What was the actual current of the GPS itself ?

$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

itmoto

The GPS was itself drawing 22-26mA in normal mode then dropped down to 1.1mA in standby mode.

srnet

So why were you asking if the 'the regulator' was using 800uA ?
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

itmoto

#43
Dec 06, 2017, 09:15 am Last Edit: Dec 06, 2017, 09:39 am by itmoto
Because it says in the datasheet:

"User can issue software command to make GPS module go into standby mode that consumes less than 200uA current"

which is less than my measured 1.1mA.

The 800uA was the difference between and whether my module has an onboard regulator (sorry I should have been clearer)
I posted an image of the module on one of my other posts. (18th Nov 2017)


From your previous post on 2nd sept 2017 you wrote:

"This is the measured power consumption in inactive mode;

Ubloc Neo 6M - 75uA
Ublox Max 8Q - 35uA

These are the bare GPS, no extra stuff connected."

Were you  using a module similar to mine (pictured in one of my other post) or were you using the bare Ublox chip to record the lower power consumption.
(I know my module doesn't have the same chip)

srnet

The 800uA was the difference between and whether my module has an onboard regulator (sorry I should have been clearer)
I
Yes you should.

So your not measuring the current consumption of the GPS itself at all, but the current consumption of the  GPS and some other associated components.

Until you do measure the current consumption of the GPS itself, you wont know if your commands are working properly or not. 

 
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

Go Up