Estoy trabajando en el registro de valores GPS (del módulo GPS u-blox Neo 6m) en una tarjeta SD usando un Arduino Pro Mini.
El código con el que estoy trabajando funciona sin fallas cuando conectamos el Arduino a la computadora portátil con un cable USB (la fuente de alimentación es del puerto USB).
Una vez que ejecuto mi programa, todas las coordenadas GPS junto con otros datos se guardan en la tarjeta SD.
Tan pronto como cambio mi energía a dos baterías CR2032 en serie y suministre el voltaje al pro mini, los datos llegan durante unos diez segundos y luego el LED (pin13) comienza a parpadear súper rápido (no estoy codificando nada para el pin13 que no sea el sck del módulo de la tarjeta sd para la comunicación spi).
Luego se me ocurrió que tal vez dos baterías no serían suficientes, así que usé tres baterías CR2032 en serie y luego verifiqué la configuración. Ahora todo funciona perfectamente durante aproximadamente un minuto y luego el led (pin13) comienza a parpadear y arruina el programa.
Si el LED parpadea rápido, no se guardan datos en la tarjeta SD.
No estoy seguro de cómo resolver el problema. Tal vez la corriente sea el problema aquí, pero no puedo usar otras baterías que no sean CR2032.
¿Puede alguien ayudarme?
código que he usado
#include <TinyGPS++.h> // Include the TinyGPS++ library
TinyGPSPlus tinyGPS; // Create a TinyGPSPlus object
#include <SD.h>
#include <SPI.h>
#define GPS_BAUD 9600 // GPS module baud rate. GP3906 defaults to 9600.
#include <Wire.h>
// If you're using an Arduino Uno, RedBoard, or any board that uses the
// 0/1 UART for programming/Serial monitor-ing, use SoftwareSerial:
#include <SoftwareSerial.h>
#define ARDUINO_GPS_RX 2 // GPS TX, Arduino RX pin
#define ARDUINO_GPS_TX 3 // GPS RX, Arduino TX pin
SoftwareSerial ssGPS(ARDUINO_GPS_TX, ARDUINO_GPS_RX); // Create a SoftwareSerial
#define SDFILE_PIN_CS 10
// Set gpsPort to either ssGPS if using SoftwareSerial or Serial1 if using an
// Arduino with a dedicated hardware serial port
#define gpsPort ssGPS // Alternatively, use Serial1 on the Leonardo
File sdFile;
// Define the serial monitor port. On the Uno, and Leonardo this is 'Serial'
// on other boards this may be 'SerialUSB'
#define SerialMonitor sdFile
void setup()
{
Serial.begin(9600);
gpsPort.begin(GPS_BAUD);
pinMode(SDFILE_PIN_CS, OUTPUT);
if (!SD.begin()) {
Serial.println(F("Card failed, or not present"));
while(1);
}
Serial.println(F("card initialized."));
}
void loop()
{
sdFile = SD.open("datalog.txt", FILE_WRITE);
if (sdFile) {
// print position, altitude, speed, time/date, and satellites:
printGPSInfo();
// "Smart delay" looks for GPS data while the Arduino's not doing anything else
smartDelay(1000);
sdFile.close();
// Uncomment to print to the serial port
//Serial.println("ENTER SENSOR DATA HERE");
}
else {
// if the file didn't open, print an error
Serial.println(F("error opening file."));
}
}
void printGPSInfo()
{
// Print latitude, longitude, altitude in feet, course, speed, date, time,
// and the number of visible satellites.
printDate();
SerialMonitor.print("\t");
printTime();
SerialMonitor.print("\t");
SerialMonitor.print(tinyGPS.altitude.meters());
SerialMonitor.print("\t");
SerialMonitor.print(tinyGPS.speed.mps());
SerialMonitor.print("\t");
SerialMonitor.print(tinyGPS.satellites.value());
SerialMonitor.print("\t");
SerialMonitor.print(tinyGPS.location.lat(), 6);
SerialMonitor.print("\t");
SerialMonitor.println(tinyGPS.location.lng(), 6);
}
// This custom version of delay() ensures that the tinyGPS object
// is being "fed". From the TinyGPS++ examples.
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
do
{
// If data has come in from the GPS module
while (gpsPort.available())
tinyGPS.encode(gpsPort.read()); // Send it to the encode function
// tinyGPS.encode(char) continues to "load" the tinGPS object with new
// data coming in from the GPS module. As full NMEA strings begin to come in
// the tinyGPS library will be able to start parsing them for pertinent info
} while (millis() - start < ms);
}
// printDate() formats the date into dd/mm/yy.
void printDate()
{
SerialMonitor.print(tinyGPS.date.day());
SerialMonitor.print("/");
SerialMonitor.print(tinyGPS.date.month());
SerialMonitor.print("/");
SerialMonitor.print(tinyGPS.date.year());
}
// printTime() formats the time into "hh:mm:ss", and prints leading 0's
// where they're called for.
void printTime()
{
SerialMonitor.print(tinyGPS.time.hour());
SerialMonitor.print(":");
if (tinyGPS.time.minute() < 10) SerialMonitor.print('0');
SerialMonitor.print(tinyGPS.time.minute());
SerialMonitor.print(":");
if (tinyGPS.time.second() < 10) SerialMonitor.print('0');
SerialMonitor.print(tinyGPS.time.second());
}
```
¡Tuve un problema similar con CR2032 en uno de mis primeros proyectos! CR2032 simplemente no puede suministrar suficiente corriente, su voltaje cae inutilizable tan pronto como extraiga algo significativo para alimentar la MCU (tenía la píldora azul STM32 y sacó un solo CR2032 nominal 3.2V casi inmediatamente hasta el límite de 2.65V con CR2032 completamente nuevo ).
La solución para mí fue reemplazarlo con un pequeño li-io de 250 mah, es solo un poco más grande que el CR2032 y ciertamente comparable a dos CR2032 en tamaño mientras es recargable y brinda la potencia requerida sin ningún problema. Pero sí, los niveles de voltaje son diferentes, lo sabes.
Los requisitos son los requisitos por supuesto, pero no puedes volar si remas, es una tarea imposible para CR2032 (estamos hablando de cosas prácticas y realistas y no de 25 baterías en paralelo), como señalaron muchos por aquí. Solo tiene que probar este punto y optar por un pequeño 150 mah - 300 mah (que es totalmente comparable a CR2032 por cierto). ¡Trabajó para mi!
Una batería CR2032, o muchas en serie, quizás podrían encender el Arduino.
Guardar datos en la tarjeta SD puede tomar ráfagas de corriente de hasta 300 mA según la marca/modelo/grado de velocidad de la tarjeta SD.
Un fabricante de baterías CR2032 dice que la corriente máxima extraída de la batería es de 10 mA, por lo que podría ser posible conectar en paralelo hasta 30 baterías para que funcione, si ese es el requisito.
En resumen, no hay una forma práctica de hacerlo con baterías CR2032.
chris stratton
JRE
Hilmar
andres morton
Matti Virkkunen
Aldrín
Aldrín
chris stratton
chris stratton
Aldrín
chris stratton