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