GPS(EM406a) Confusion(serial problem i think)

Hello, i am using a EM406a GPS module with an Arduino Uno R3.

I am attempting to connect the 2 together and then receive and format the information gained.

I found some code in a previous thread that looks like this ( and saved me a lot of stressing, thank you)

void setup(){
  pinMode(0,INPUT);
  digitalWrite(0,LOW);
  pinMode(1,INPUT);
  digitalWrite(1,LOW);
}

void loop(){
  while(1);
}

Using this i get a dump of:

$GPGGA,150210.000,5116.2428,N,00104.4570,E,1,04,2.7,28.1,M,47.0,M,,0000*6E
$GPGSA,A,3,08,07,26,28,,,,,,,,,5.0,2.7,4.2*35
$GPRMC,150210.000,A,5116.2428,N,00104.4570,E,0.13,66.98,210312,,,A*55

Which seems to be the correct information...

As soon as i begin to use Serial.begin(4800); which is the baud rate of the GPS, i begin to just receive -1 from the COM reader.

Any help is appreciated and ill probably be checking back here every 10 mins til I get this sorted, and am willing to test/try anything.

EDIT: Using SirfDemo and connecting at COM5/4800 and checking the settings seeing that "Switch to NMEA protocol" is greyed meaning it is using this protocol and i get information through to the sirfdemo software showing 5 satellite locks.

the code snipped you are posting confuses me. Are you somehow bipassing your arduino and directly reading the output from your GPS via serial?

Is your gps connected to pin 0 and 1?

pin zero and one are used for serial communication with your computer. you can either use them for a serial connection or for reading or writing to, not both.

this is what I think is going on: you seem to be writing the gps data directly to your serial port and reading it with your computer, bipassing the arduinos controller. as soon as you say "serial.begin(4800)" you are attempting to run two different serial connections over the same pins, which is bound to fail. (this is some speculation - I did not even know it was possible to do this, and I could be really far off as well...)

not 100% sure about this, but I think there is a software serial library which might be of help.

Hmm I tried to switch to port 2/3 and cannot seem to get anything up in the serial COM reader :confused: using:

void setup(){
  pinMode(3,INPUT);
 // digitalWrite(2,LOW);
  pinMode(2,OUTPUT);
 // digitalWrite(3,LOW);
  Serial.begin(4800);
}

void loop(){
  while(1);
  Serial.print(Serial.read());Serial.println("\n");
 // digitalRead(0);
}

OK, i think ive found something after using the TinyGPS example Simple_test and adjusting very few things i got it finally working i did a factory reset through SirfDemo and then set it at NMEA/4800 and things seem to go well using the tinyGPS and softserial with it :smiley:

Thank you for help on the tx/rx pins or i wouldnt have tried it

Hmm I tried to switch to port 2/3

Is your GPS taking to pins 2 and 3?

Because you aren't reading from those pins.

Your stupid infinite loop inside loop is preventing loop() from doing anything.

i stopped using that and used TinyGPS which uses pins 3/4 and this code:

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 3(rx) and 4(tx).
*/

TinyGPS gps;
SoftwareSerial ss(3, 4);

void setup()
{
  Serial.begin(115200);
  ss.begin(4800);
  
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
}

void loop()
{
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print("LAT=");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
  }
  
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(chars);
  Serial.print(" SENTENCES=");
  Serial.print(sentences);
  Serial.print(" CSUM ERR=");
  Serial.println(failed);
}

and i get the information perfectly.

But now i start to use my own code and all i get is random numbers though the pins again :confused:

Do you know why your original code did not work?
Do you understand why this code works?

Go threw the working code bit by bit. Experiment with it, delete things and see what happens. When you feel like you really understand it, then you are ready to write your own.

You also might want to try some basic arduino examples - like blinking an led etc. Might not seem interesting but will help you understand the language...

I went back and started going though the tinyGPS examples so i could get around their library but after browsing the examples and keywords file I find myself being able to use its basic features but not being able to use the more advanced keywords and cannot find any information on the Arduiniana site.

Does anybody know of a resource that has information on the TinyGPS keywords and library please.

Thank you for all information so far :slight_smile:

you dont want to "get around" using their library. Doing work someone else has done seems pretty pointless to me.

but: you need to understand it.

I just took a look at the code, and it is pretty basic. There is nothing in there, which you can not figure out by checking the basic Arduino documentation here: http://arduino.cc/it/Reference/HomePage

Also, I would advise you to do some simpler things with arduino to understand its basic features. I would have been overtaxed if this was my first sensor.

Try going though the code, line be line, and making sure you understand what is happening.

If you asked specific questions I will try to answer them.

p.