GPS with Arduino UNO.

Hello,

I’m facing a serious problem in making the Sirf Star iii EM-408 GPS work, it outputs for me some weird characters on the serial screen, I’m sure about my baud rate and here’s the code that my GPS is working on:

#include <SoftwareSerial.h>

SoftwareSerial GpsMod = SoftwareSerial(2,3);

void setup()
{
GpsMod.begin(4800);
Serial.begin(9600);
}

 void loop()
{
Serial.write(byte(GpsMod.read()));
}

I’ve also attached a screenshot of the results I’m getting, so, I hope I’ve gave enough information about the problem…

Capturez.PNG

RS232 or TTL?

speed problem.

Try change GPS speed to 9600

Serial windows speed is set according to "serial.begin"

Remove word "byte" when printing

AWOL: RS232 or TTL?

Thanks for your response, it's a TTL.

knut_ny: speed problem.

Try change GPS speed to 9600

Serial windows speed is set according to "serial.begin"

Remove word "byte" when printing

Thanks for your response, I'll try this and update you with the results today !.

Your loop( ) function looks wrong to me. Shouldn't you be checking if a serial input char is "available", before reading one ?

Yes You should check to see something is there before reading it, but that only explains the y with umlaut.

knut_ny: speed problem.

Try change GPS speed to 9600

Serial windows speed is set according to "serial.begin"

Remove word "byte" when printing

Unfortunately, it still didn't help. Btw, I can't remove "byte", because it outputs for me the data, even though, I tried removing the byte and it didn't output for me anything. I've also tried increasing the GPS's speed and it didn't help at all, 4800 seems just fine.

michinyon:
Your loop( ) function looks wrong to me. Shouldn’t you be checking if a serial input char is “available”, before reading one ?

Is this’s what you mean ??.

while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read(); 
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
     } 
  }
}

If so, do you suggest putting it in the main loop or put it in a function and refer to it from the main loop ?!!.

Thanks.

I've read something interesting in the GPS's datasheet, but I didn't fully understand it, and the solution could be there. It says explaining the RX: "When not in use this pin must be kept “HIGH” for operation.". I couldn't understand what they mean by "HIGH" as I haven't pinned anything to my RX on the arduino board. Here's the link for it's datasheet: http://www.usglobalsat.com/store/download/47/em408_ug.pdf. So, do I need the RX in my wiring based on what's explained in the datasheet ??. And, is it necessary to use RX in order to get the readings or is TX just enough for it ?!!.

it defaults to NMEA messages at 4800 baud, 1 stop bit and no parity. The default NMEA messages outputted are GSA, GSV and RMC.

Ref: http://geoffg.net/EM408.html

The data sheet is correct in that Rx needs a pull-up resistor. I would try a 10K unless you just happen to have that value of zener lying around.

The GPS module is a dedicated (likely masked) microcontroller in its own right. So, if you change anything from power-on defaults you must send a properly constructed command line back to that Rx lead… This interrupts the GPS to read the TTL serial data stream.

This is thee sample sketch for the EM-406, so it should help:
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Dev/Arduino/Boards/gps_arduino_1_0.ino

Ray

IDE 1.0.5 / UNO / Read Serial GPS

// minimum test code for serial gps

#include <SoftwareSerial.h>

SoftwareSerial gps(3,4); // RX, TX  Connect GPS TX to pin 3 (UNO pin 4 - no need to be used)
void setup()
{
  Serial.begin(115200);  // faster than read GPS
  gps.begin(4800);  // may be 9600 or even faster

}

void loop()
{
  if (gps.available())  Serial.write(gps.read());
}

knut_ny:
IDE 1.0.5 / UNO / Read Serial GPS

// minimum test code for serial gps

#include <SoftwareSerial.h>

SoftwareSerial gps(3,4); // RX, TX  Connect GPS TX to pin 3 (UNO pin 4 - no need to be used)
void setup()
{
  Serial.begin(115200);  // faster than read GPS
  gps.begin(4800);  // may be 9600 or even faster

}

void loop()
{
  if (gps.available())  Serial.write(gps.read());
}

Still, it’s outputting the same strange characters !.

Before I go to the software part, I need to make sure of the physical part first so I could make sure that the problem is not from it !!. The GPS’s manual says describing the RX: From Vcc connect a 470 Ohm resistor in series with a 3.2v Zener diode to Ground. Then, connect the Rx input to Zener’s cathode, so, I’m going to attach a photo and I want you guys to comment on it if there’s anything wrong in it !.
The grey wire is the 5v or vcc, the white one is for the ground, and the purple one is for the TX.

Ummmmm.... From my previous link:

Two Versions

Amazingly there are two versions of the EM-408 with the same part number. The standard version uses TTL voltage levels on its serial output (idle is 2.7V, the start bit and logic 0 are zero volts). The alternative uses RS-232 voltage levels and polarity (idle is -6.8V, the start bit and logic 0 are +6.8V). The only way that you can tell the difference is by physically looking at the module. The TTL version has the shield extended over the connector as shown in the photo at the top of this page while the RS-232 version does not have this feature as shown in the photo on the right. The documentation only refers to the TTL version and when you are ordering one of these modules you have no idea of what one you are going to receive as the part numbers (EM-408) are the same. It is incredible that a supplier would create such confusion in the market place and unfortunately their crime is compounded by the dreadful documentation that they supply. dx.com has a very cheap TTL/RS-232 converter board (link) that you can use to convert from one to the other. There is also a later version on the market called EM-408E. It looks like the RS-232 version (without the extended shield) but what documentation is supplied claims that its output uses TTL voltage levels. I have not tested this version but it appears to have a few other differences including replacing the enable input with a battery backup input.

mrburnette: Ummmmm.... From my previous link:

Two Versions

Amazingly there are two versions of the EM-408 with the same part number. The standard version uses TTL voltage levels on its serial output (idle is 2.7V, the start bit and logic 0 are zero volts). The alternative uses RS-232 voltage levels and polarity (idle is -6.8V, the start bit and logic 0 are +6.8V). The only way that you can tell the difference is by physically looking at the module. The TTL version has the shield extended over the connector as shown in the photo at the top of this page while the RS-232 version does not have this feature as shown in the photo on the right. The documentation only refers to the TTL version and when you are ordering one of these modules you have no idea of what one you are going to receive as the part numbers (EM-408) are the same. It is incredible that a supplier would create such confusion in the market place and unfortunately their crime is compounded by the dreadful documentation that they supply. dx.com has a very cheap TTL/RS-232 converter board (link) that you can use to convert from one to the other. There is also a later version on the market called EM-408E. It looks like the RS-232 version (without the extended shield) but what documentation is supplied claims that its output uses TTL voltage levels. I have not tested this version but it appears to have a few other differences including replacing the enable input with a battery backup input.

Well, according to the link, my GPS is RS-232, and, according to the same link, this's what it says !!: "RS-232 Version Output

If you are connecting this version to a microcontroller you will need to use an interface chip like the MAX232 to convert the output to TTL levels and signaling polarity. An alternative is to clamp the output to +5V/0V using a resistor and diode then invert the serial data stream in software in the microcontroller.". But, is the arduino considered as a microcontroller, and therefore, I'll need the MAX232 ?!!.

Arduino is the board and GUI programming environment, Atmega328P is the microcontroller

If RS232 you will need the interface chip or you can search Google for discrete circuits to do similar. I wish you had followed and read the link when I posted it... I really do not like to cut&paste from others blogs.

Ray

mrburnette: Arduino is the board and GUI programming environment, Atmega328P is the microcontroller

If RS232 you will need the interface chip or you can search Google for discrete circuits to do similar. I wish you had followed and read the link when I posted it... I really do not like to cut&paste from others blogs.

Ray

Do you mean I need both microcontroller and Arduino ??. Or, just take the microcontroller and leave the arduino ?!!.

Arduino boards all have microcontrollers.

Arduino is not the microcontroller.

But, if you have an RS232 signal you must condition it before attaching it to the Arduino board (which subsequently connects it to the embedded microcontroller.)

Ray

mrburnette: Arduino boards all have microcontrollers.

Arduino is not the microcontroller.

But, if you have an RS232 signal you must condition it before attaching it to the Arduino board (which subsequently connects it to the embedded microcontroller.)

Ray

Ah, ok, thanks for clearing my confusion !!. But, do you think that this's why I'm getting these weird characters ?!!. Cuz I just found this guy having my problem, but with a different GPS.. !: http://forum.arduino.cc/index.php?topic=216531.0.