gps neo6 and LowPower problem

Hi.
I am doing a project with Arduino Pro mini 5v 16Mhz, sd-card (pins:10,11,12,13), LM35 sensor (pin A0) and gps neo6m (pins 4,3).
Every 10 seconds I save the latitude, longitude, speed, date and time that the gps plus the sensor temperature return in the micro-sd.
Every 40 seconds I pause for 1 minute.
Everything works fine but if I use
LowPower.powerDown (SLEEP_8S, ADC_OFF, BOD_OFF) ;
instead of
delay(1000 * 10);
it doesn't pause and I had to change the SoftwareSerial library for the gps to NeoSWSerial because when I printed the data with Serial.print that I got from the gps it came out weird symbols.

Is there any incompatibility between libraries, or what am I doing wrong?

This is a summary of the code


#include <SPI.h>
#include <SD.h>
#include <NeoSWSerial.h>

NeoSWSerial gpsSerial( 4, 3 );

File myFile;
const int chipSelect = 10;  // pin for SS/CS
char leido;
unsigned int estado = 0; 
float fTemp;
const unsigned char cfgGpsOff[] = 
  { 0xB5,0x62,0x06,0x04,0x04,0x00,0x00,0x00,0x08,0x00,0x16,0x74 };
const unsigned char cfgGpsOn[] = 
  { 0xB5,0x62,0x06,0x04,0x04,0x00,0x00,0x00,0x09,0x00,0x17,0x76 };
...

void setup() {
  Serial.begin(9600);
  gpsSerial.begin(9600);

  if (!SD.begin()) {
    Serial.println("initialization failed");
    return;
  }
}

void loop(void) { 
  while (gpsSerial.available() > 0) {
    leido = gpsSerial.read();
    ...
   }

   if (latitud != ' ') {
      fTemp = readLM35();
      myFile = SD.open("testSD.txt", FILE_WRITE);
  
      if (myFile) {
        myFile.print(latitud);
        ...
      }

      estado++;
      if (estado == 5) {
         sendUBX(cfgGpsOff, sizeof(cfgGpsOff) );
      }
   }
   
   if (estado < 5) {
     delay(1000 * 15); // 15 secs pause, OK
     LowPower.powerDown (SLEEP_8S, ADC_OFF, BOD_OFF) ; // This doesn't work
   }
   else {
     delay(1000 * 32);  // 64 secs pause. OK
     delay(1000 * 32);
     for (estado = 8; estado > 0; estado--)
          LowPower.powerDown (SLEEP_8S, ADC_OFF, BOD_OFF) ; // This doesn't work
     estado = 0;
     sendUBX(cfgGpsOn, sizeof(cfgGpsOn) );
   }
}

SoftwareSerial and Serial.Print() dont mix well, and yes weirs symbols on the serial monitor is one of the symptoms.

Explanation of the problems is here; SoftwareSerial Problems

NeoSWSerial does not have the same problems.

srnet:
SoftwareSerial and Serial.Print() dont mix well, and yes weirs symbols on the serial monitor is one of the symptoms.

Explanation of the problems is here; SoftwareSerial Problems

NeoSWSerial does not have the same problems.

Thank's.
From now on I will always use NeoSWSerial instead of SoftwareSerial.
But it does not work LowPower and I do not know why.

chavalot:
But it does not work LowPower and I do not know why.

Interesting, do we have to guess what you mean by that ?

srnet:
Interesting, do we have to guess what you mean by that ?

Does not pause for 8 seconds and continues.

Are you using the LowPower library from GitHub - rocketscream/Low-Power: Low Power Library for Arduino ?

Have you tried flashing the example from Low-Power/powerDownWakePeriodic.ino at master · rocketscream/Low-Power · GitHub

Start at the beggining.

Try an example with just the 8 second sleep, no GPS or SD, make sure that works then start adding bits.

Yes, It's that library and this works ok:

#include <NeoSWSerial.h>
#include "LowPower.h"
#include <SPI.h>
#include <SD.h>

bool bestado = false;
const int pinled = 10;

void setup()
{
   Serial.begin(9600);
   pinMode(LED_BUILTIN, OUTPUT);
   pinMode(pinled, OUTPUT);
}

void loop() 
{
    // Enter power down state for 8 s with ADC and BOD module disabled
    LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF);  
    
    if (bestado) {
      digitalWrite(LED_BUILTIN, HIGH);
      digitalWrite(pinled, LOW);
      bestado = false;
    }
    else {
      digitalWrite(LED_BUILTIN, LOW);
      digitalWrite(pinled, HIGH);
      bestado = true;
    }
    
    Serial.print("Estado= "); Serial.println(bestado); Serial.flush();
}

This afternoon I will be able to continue testing.

Hi again.
When use the GPS the LowPower.powerDown doesn't stop and continuous the program and the GPs returns weird characteres:
$GPRMC,113332.00,A⸮⸮⸮⸮⸮0764,N,00---0.26928,W1020 %⸮ ⸮⸮⸮⸮⸮⸮⸮r⸮⸮

maybe i have to sleep also to the gps during that time that the arduino sleeps ?

I think i'm right in saying that the serial port, both hardware and software variants, use interrupts. If that is the case, then an interrupt will wake the chip from sleep mode.

This works well:
Turn off the RF GPS.
Some delays between commands (give time to change state) and the LowPower.
Turn on the RF GPS.

sendUBX( cfgGpsOff, sizeof(cfgGpsOff) );
delay(1000 * 30);
delay(1000 * 10);
for (estado=100; estado>0; estado--)
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
delay(1000 * 30);
sendUBX( cfgGpsOn, sizeof(cfgGpsOn) );
delay(1000 * 30);

markd833:
I think i'm right in saying that the serial port, both hardware and software variants, use interrupts. If that is the case, then an interrupt will wake the chip from sleep mode.

I think so too.
Thank's for the help and this topic can be closed.

You did not post all the code (hint!!!) so its difficult to be sure, but a gpsSerial.flush(); after sending the config commands to the GPS might achieve the same as the delays.