GPS module won't run on battery

rdfowler

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
I have been unable to get the GPS module to run on a battery. It will run using the USB shield connected to a USB port on my computer. I suspect the battery can't supply enough power. Is there anything I can do?


Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 392
    • View Profile
It should be able to, unless it's a coin cell- can you link/post the code you're using? I'll check if it seems like it's turning the module on correctly.


rdfowler

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
Here is the code. It was downloaded from the Tiny Circuits a while back. It's supposed to write the GPS information to a SD card:
  /*
     This Arduino sketch will log GPS NMEA data to a SD card every second
  */
  #include <SPI.h>
  #include <SoftwareSerial.h>
  #include <SD.h>
 
 
  // The Arduino pins used by the GPS module
  static const int GPS_ONOFFPin = A3;
  static const int GPS_SYSONPin = A2;
  static const int GPS_RXPin = A1;
  static const int GPS_TXPin = A0;
  static const int GPSBaud = 9600;
  static const int chipSelect = 10;
 
  // The GPS connection is attached with a software serial port
  SoftwareSerial Gps_serial(GPS_RXPin, GPS_TXPin);
 
 
  void setup()
  {   
    // Init the GPS Module to wake mode
    pinMode(GPS_SYSONPin, INPUT);
    pinMode(GPS_ONOFFPin, OUTPUT);
    digitalWrite( GPS_ONOFFPin, LOW );   
    delay(5);
    if( digitalRead( GPS_SYSONPin ) == LOW )
    {
       // Need to wake the module
      digitalWrite( GPS_ONOFFPin, HIGH );
      delay(5);
      digitalWrite( GPS_ONOFFPin, LOW );     
    }
       
   
    // Open the debug serial port at 9600
    Serial.begin(9600);
   
    // Open the GPS serial port 
    Gps_serial.begin(GPSBaud); 
     
    Serial.print("Initializing SD card...");
    // make sure that the default chip select pin is set to
    // output, even if you don't use it:
    pinMode(10, OUTPUT);
   
    // see if the card is present and can be initialized:
    if (!SD.begin(chipSelect)) {
      Serial.println("Card failed, or not present");
      // don't do anything more:
      return;
    }
    Serial.println("card initialized.");   
  }
 
 
  int inByte = 0;         // incoming serial byte
  byte pbyGpsBuffer[100];
  int byBufferIndex = 0;
 
  void loop()
  {
    byte byDataByte;
   
    if (Gps_serial.available())
    {
       byDataByte = Gps_serial.read();
     
       Serial.write(byDataByte);
       pbyGpsBuffer[ byBufferIndex++ ] = byDataByte;
       
       if( byBufferIndex >= 100 )
       {
         byBufferIndex = 0;       
         File dataFile = SD.open("gps.txt", FILE_WRITE);
     
         // if the file is available, write to it:
         if (dataFile) {
          dataFile.write(pbyGpsBuffer, 100);
          dataFile.close();
        } 
        // if the file isn't open, pop up an error:
        else {
          Serial.println("error opening gps.txt");
        }       
       }     
    }
  }


rdfowler

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
I was finally able to get the battery to work by jump starting it with the USB shield. I hooked up the battery and the USB shield. I then connected the USB shield to a computer USB port. The program started (the LEDs started flashing). I then removed the USB shield and the program continued to run.


rdfowler

  • Jr. Member
  • **
    • Posts: 7
    • View Profile
Ok, I found the fix. It was in another Forum question. Apparently you have updated software that fixes everything. After I loaded the software everything worked. The original code was from the "Cat Tracker" project at makezine.com. I think you should have tested the project before you published it! https://codebender.cc/sketch:60928#TinyShield_GPS_V2.ino


Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 392
    • View Profile
Sorry about the old code and the delay in response- the Make article is over two years old and all of the boards are new revisions with update code etc. It looks like you may have posted the current software in the comments, thank you.


 

SMF spam blocked by CleanTalk