And i receive continuous data. (it's normal i know)
But i want to receive data only on request, and i don't know how can I modify the code to do this.
Can you help me ? Thanks
seems you are on a MEGA, right? in which case this is not neeeded
// Wait for the serial device to be ready
while (!Serial);
while (!Serial1);
To your question, you need to look at the documentation of the module and page 18 the periodic mode for example. You would use the Serial1 line to send PMTK proprietary commands input to the module to configure it in the setup()
The other thing is you can just ignore the data flow coming in if you don't worry about it for a while, it will overflow the Serial1 buffer but that's no big deal, just make sure that when you want to read the location, first you need to find a proper end of frame and read the next full one.
Powering down the module would probably be counter productive as when you'll need to read info it can take up to 30 seconds to find your location again. I would suggest you adjust the update rate and sleep times to something matching your update pace need and energy goals and just read when necessary
I use an arduino Due for the first tests, but after i will use an ATtiny441.
On the GPS i just want to receive the line '$GPRMC' when i want. Is it possible ?
To recapitulate, the GPS is mute, and just with a request receive the datas only one time ?
Thanks
You need to read the documentation pointed above for the different modes
and pick the one you want.
Example:
PMTK225,2,3000,12000,18000,72000*15 for periodic mode with 3s in tracking mode and 12s in standby mode based on GPS&GLONASS. The average current consumption is calculated as below:
I periodic= (I tracking×T1+I standby×T2 )/(T1+T2)=(26mA×3s + 1mA×12s)/(3s+12s)=6 (mA)
PMTK225,1,3000,12000,18000,72000*16 for periodic mode with 3s in tracking mode and 12s in backup mode based on GPS&GLONASS. The average current consumption is calculated as below:
I periodic= (I tracking×T1+I backup×T2)/ (T1+T2)=(26mA×3s + 0.007mA×12s)/(3s+12s)≈5.2(mA)
then I'd suggest you get yourself familiar with various coding techniques