0
\$\begingroup\$

I'm working on logging GPS values(from u-blox Neo 6m GPS module) to an SD card using an Arduino Pro Mini.

The code I'm working with works without any flaw when we connect the Arduino to the laptop with a USB cable (power source is from the USB port.)

Once I run my program, all the GPS coordinates along with other data gets saved on the SD card.

As soon as Ichange my power to two CR2032 batteries in series and supply the voltage to the pro mini, data comes for about ten seconds and then the led (pin13) starts blinking super fast (I'm not coding anything to pin13 other than the sck from sd card module for spi communication.)

Then it occured to me that maybe two batteries will not be sufficient, so I used three CR2032 batteries in series and then checked the setup. Now everything works perfectly for about a minute and then snap the led (pin13) starts blinking and ruins the program.

If the led blinks fast, no data gets saved on the SD card.

I'm not sure as to how to solve the problem. Maybe the current is the issue here, but I can't use any other batteries other than CR2032.

Can anyone help me out?

code ive used

#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());
}
```
\$\endgroup\$
  • 1
    \$\begingroup\$ I can't use any other batteries other than CR2032." Whoever imposed this requirement has set you up for failure. \$\endgroup\$ – Chris Stratton Jun 19 at 15:04
  • \$\begingroup\$ Assuming you really mean an Arduino Pro Mini (not the Uno you also mention) you should be able to get a longer run time out of it. You'll have to get really into the power saving modes of the Arduino and the GPS receiver, though. Post your code. \$\endgroup\$ – JRE Jun 19 at 15:12
  • \$\begingroup\$ Look at the current requirements of your specific Arduino. Look at the max current that a CR2032 can deliver. Quite likely you have a null set and you got lucky that you didn't cook the batteries \$\endgroup\$ – Hilmar Jun 19 at 15:13
  • 1
    \$\begingroup\$ Also, look at the Indicative power requirements for the GPS unit and compare that to what a CR2032 cell can supply. It does not look good. \$\endgroup\$ – Andrew Morton Jun 19 at 15:28
  • \$\begingroup\$ Putting batteries in series will not increase the current capacity, but rather the voltage which can end up damaging things. Did you mean parallel? \$\endgroup\$ – Matti Virkkunen Jun 19 at 15:47
0
\$\begingroup\$

I had a similar problem with CR2032 in one of my very first projects! CR2032 simply can't supply enough current, its voltage falls into unusable as soon as you pull anything significant to power the MCU (I had STM32 blue pill and it pulled single CR2032 nominal 3.2V almost immediately down to borderline 2.65V with full fresh CR2032).

The sulution for me was to replace it with a tiny 250mah li-io, it's only slightly greater than CR2032 and certainly comparable to two CR2032 in size while being rechargeable and giving the required power without a problem. But yeah, voltage levels are different, you know it.

Requirements are requirements of course, but you can't fly if you wave oars, it's an impossible task for CR2032 (we're talking about practical realistic stuff and not 25 batteries in parallel), as many around here pointed out. You just have to prove this point and srsly go for a tiny 150mah - 300mah (which is totally comparable to CR2032 btw). Worked for me!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

A CR2032 battery, or many in series, could perhaps power up the Arduino.

Saving data to the SD card can take bursts of current up to 300 mA depending on the SD card make/model/speedgrade.

One CR2032 battery manufacturer says the maximum current drawn from battery is 10mA, so it might be possible to parallel up to 30 batteries to make it work, if that is the requirement.

So in short, there is no practical way do it with CR2032 batteries.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.