0

I'm working on my project car, and I have decided I would like to have a GPS and log some sensors too. I'm just at a bottle neck here, the sensors I have brought pull about 7v each where I can't pull that much from the breakout board that I have, and I can't seam to get the GPS to work.

I've tried using ths code but software serial isn't supported on the edison:

// GPS Setup
#define rxGPS 0
#define txGPS 1
SoftwareSerial serialGPS = SoftwareSerial(rxGPS, txGPS);
String stringGPS = "";

void setup() {
  pinMode(rxGPS, INPUT);
  pinMode(txGPS, OUTPUT);


  Serial.begin(9600);
  Serial.println("Started");

  // GPS Setup
  serialGPS.begin(4800);
  digitalWrite(txGPS,HIGH);

  // Cut first gibberish
  while(serialGPS.available())
    if (serialGPS.read() == '\r')
      break;
}

void loop()
{
  String s = checkGPS();
  if(s && s.substring(0, 6) == "$GPGGA")
  {
    Serial.println(s);
  }
}

// Check GPS and returns string if full line recorded, else false
String checkGPS()
{
  if (serialGPS.available())
  {
    char c = serialGPS.read();
    if (c != '\n' && c != '\r')
    {
      stringGPS  = c;
    }
    else
    {
      if (stringGPS != "")
      {
        String tmp = stringGPS;
        stringGPS = "";
        return tmp;
      }
    }
  }
  return false;
}

Any ideas or help would be much appreciated

3
  • 1
    "Sensors pull 7V"? Hmm? Do they pull 7A? Or they need to be powered from 7V?
    – Alex
    Jun 9, 2015 at 11:57
  • 1. stringGPS += c;
    – Alex
    Jun 9, 2015 at 11:59
  • 2. checkGPS() returns String and you have "return false" at the end
    – Alex
    Jun 9, 2015 at 12:00

2 Answers 2

1

Try this:

String GPSLine;

bool checkGPS()
{
  while(serialGPS.available())
  {
    char c = serialGPS.read();
    if(c == '\n') return true;
    if(c == '\r') continue;

    GPSLine += c;
  }
  return false;
}

void loop()
{
  if(checkGPS())
  {
    Serial.println(GPSLine);
    GPSLine = "";
  }
}
3
  • requiring any libraries?
    – bedrock
    Jun 10, 2015 at 9:14
  • Okay well to break up what I'm doing
    – bedrock
    Jun 10, 2015 at 14:22
  • 1 I have the Intel Edison one breakout board it has a micro SD card slot and I want to take the gps and log everything that it sends to a SD card and the second part is to read and display sensors onto a screen. But for now I just want to get the gps working
    – bedrock
    Jun 10, 2015 at 14:26
0

You might try my NeoGPS library. It has a diagostic program and some good information in the Troubleshooting section. And NeoGPS doesn't use the String class, although you can safely waste lots of RAM on the Edison. :P

For an Edison build, you may have to change the PACKED_DATA configuration item, described here.

(This is an Arduino product, right?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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