GNSS deep sleep,Help needed with sending pmtk command.

Hello everybody,

I am working on my home made Gps tracker, I am using Arduino Mega with TinyGPS++ Library to get Locations and other useful details, I am using Quectel L86 GNSS module.
I powered my system to a 3.7V Lithium Ion battery,Everything is working fine, Now I want to move a step forward and keep my system into Deep sleep.

-Firstly i want to start with the GNSS unit.
I have referred to Quectel L86 Documentation,Where i found a PMTK command “$PMTK001,161,3*36” ,I don’t know how to send this command :frowning:
Please help me in this.

-Secondly help me on ‘How to put Arduino Mega on Deep sleep’ any tutorials might help a lot.

Thank you

the .ino file is attached with this thread.

code2.ino (13 KB)

don't know how to send this command :

There are, apparently, a lot of other things you don't know.

    while (lat0 = gps.location.lat(), lat0 == 0.0)

WTF? The comma operator has no place in a while statement.

    smartDelay(1000);

stupidDelay() is more like it.

You are pissing away memory uselessly on the String class. How do you suppose that the String class knows how to convert a float to a string? Do you REALLY think it is the only class that knows how to do that? Doesn't it seem likely that the File class would know how to do that, too?

You have the same code replicated at least 4 times. Put that code in a function, and call it 4 times.
You have the same code replicated at least 4 times. Put that code in a function, and call it 4 times.
You have the same code replicated at least 4 times. Put that code in a function, and call it 4 times.
You have the same code replicated at least 4 times. Put that code in a function, and call it 4 times.

I am using Quectel L86 GNSS module.

For what? How to you communicate with it?

Thank you @PaulS for your reply.

Thank you for the suggestions on optimizing my code.

WTF? The comma operator has no place in a while statement.

while (lat0 == 0.0)

stupidDelay() is more like it.

It should be, Yes! (I build my code using the Full Example code from the Library,Where library maker uses that one, I thought it should be important somewhere in the code.)

You are pissing away memory uselessly on the String class. How do you suppose that the String class knows how to convert a float to a string? Do you REALLY think it is the only class that knows how to do that? Doesn’t it seem likely that the File class would know how to do that, too?

I didn’t get this, please elaborate.

You have the same code replicated at least 4 times. Put that code in a function, and call it 4 times.
You have the same code replicated at least 4 times. Put that code in a function, and call it 4 times.
You have the same code replicated at least 4 times. Put that code in a function, and call it 4 times.
You have the same code replicated at least 4 times. Put that code in a function, and call it 4 times.

Thanks for this, I did the changes.

For what? How to you communicate with it?

Using Serial2.

code2.ino (9.97 KB)

I didn't get this, please elaborate.

Tell me what the observed differences are between

      dataFile.print(String(lng1, 6));

and

      dataFile.print(lng1, 6);

Now, why do you need to piss away resources on the String class?