Go Down

Topic: Arduino Mega 2560 communicating with GPS Minimod (Read 965 times) previous topic - next topic

Aug 10, 2011, 07:33 pm Last Edit: Aug 11, 2011, 10:51 am by Lyinginbedmon Reason: 1
I am presently trying to imitate a Find Home Detector seen on Hackaday.com, with a couple improvements, but I'm having trouble getting a response from the GPS Minimod I'm using.

I have an LED ring (Mayhew labs) indicating the compass module readout and an LCD screen giving a text-based readout of the same bearing (for the moment, it'll show distance later on). I looked around for some code related to the Minimod that I could reverse engineer to get what I need, but it doesn't seem all that common.

Currently, the Minimod is hooked up to VCC to D24, Gnd on Gnd, and TX to D22 on my Arduino Mega 2560. What I need to find out are the coding requirements for using it, and ideally some code examples of its usage.
Code: [Select]
#include <NewSoftSerial.h>
#include <LiquidCrystal.h>

NewSoftSerial gps(22, 24);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup()
{
 gps.begin(4800);
 lcd.begin(16, 2);
 Serial.begin(115200);
 
 pinMode(5, OUTPUT);
 analogWrite(5, 90);
 
 pinMode(13, OUTPUT);
}

void loop()
{
 lcd.clear();
 if (gps.available()) {
   lcd.print(gps.read(), BYTE);
 }
 else {
   lcd.print("No data");
 }
 blink();
 delay(1000);
}

void blink() {
 digitalWrite(13, HIGH);
 delay(100);
 digitalWrite(13, LOW);
}
This is the current code I'm working with, but all it ever returns is No data and the GPS lock LED never initiates.

PaulS

Would you be so kind as to post a link to the GPS you are trying to talk to?

Quote
Currently, the Minimod is hooked up to VCC to D24, Gnd on Gnd, and TX to D22 on my Arduino Mega 2560.

VCC should not be connected to D24. It should be connected to something that is HIGH all the time, or 5V on the Arduino.

Quote
This is the current code I'm working with, but all it ever returns is No data and the GPS lock LED never initiates.

You are doing this outside, right?


Yes, I'm doing this outside, my house is over a century old and works very nicely to block any incoming signal. Answering a cellphone is a real pain.

So I only listen to the TX line? If so, how? Can you give some example code?

PaulS

Code: [Select]
So I only listen to the TX line? If so, how? Can you give some example code?
Usually, yes. You didn't provide a link to the device, so whether you can talk to it, meaningfully, remains a mystery.

Your code should work, once you have connected VCC to a stable, 5V source.

Managed to sort things out.

The GPS is a Sparkfun GPS Minimod, so it has only a VCC, TX, and Gnd line and there is appallingly little documentation on its usage available.

I connected VCC to the 5V line and the TX to one of the RX ports on the Mega. As it turns out the GPS constantly spews the data it retrieves into the serial port through the TX, no matter what you otherwise want it to do, so you can't just ask for one specific data point. The operating voltage for the Minimod is 3.3-6V, so I may attach it to a digital port at the VCC again to disable it when its not in use and save some power.

Consequently, I've had to code an array system that starts with the GGA header of the data and iterates with the comma separation of it to isolate each individual data point in the array so I can extract the latitude and longitude. But at least the end result is I've gotten the damn thing working.

PaulS

So, now may be the time to look into the TinyGPS library.


So, now may be the time to look into the TinyGPS library.

Attempting to, right now I'm using this to net the latitude and longitude
Code: [Select]
  while(Serial1.available()) {
    if(gps.encode(Serial1.read())) {
      gps.get_position(&curLat, &curLon, &fix_age);
 
      Serial.print("Current: ");
      Serial.print(curLon);
      Serial.print(" / ");
      Serial.println(curLat);
    }
  }
Except that it never gets a value, so my compass is always pointing North rather than towards the target destination.

Just to say I'm still having this problem, and I need a quick resolution to it as the project has a deadline of tomorrow morning.

Go Up