GPS L86 M33

Hi, i use this code for L86 M33 (GPS)

#define RESET A3
#define FORCE_ON A2
#define VBACKP 11
void setup() {

  • // put your setup code here, to run once:*

  • //Initialize serial and wait for port to open:*

  • // Initialize serial devices at 9600 bauds*

  • Serial.begin(9600);*

  • Serial1.begin(9600);*

  • // Wait for the serial device to be ready*

  • while (!Serial);*

  • while (!Serial1);*

  • // Set PIN direction*

  • pinMode(VBACKP, OUTPUT);*

  • pinMode(RESET, OUTPUT);*

  • pinMode(FORCE_ON, OUTPUT);*

  • // Reset, at least 100ms*

  • digitalWrite(RESET, LOW);*

  • delay(100);*

  • digitalWrite(RESET, HIGH);*

  • digitalWrite(VBACKP, HIGH);*

  • digitalWrite(FORCE_ON, HIGH);*

  • // prints title with ending line break*

  • Serial.println(“Serial shifter initialized”);*
    }
    void loop()
    {

  • char ch;*

  • if (Serial1.available())*

  • {*

  • Serial.print( (char)Serial1.read() );*

  • }*
    }

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

To run your main code and from time to time go do something else: Several Things at a Time

To properly handle and parse what's coming from Serial: Serial Input Basics

It's always good also when you do parsing to be familiar with Standard cstring functions
stdlib.h
string.h

this can help too
Planning and Implementing a Program