Arduino Uno and GPS EM-411 Problem

Hi there,

I am new to Arduino but already got some experience using lcd's.

I now bought a EM-411 GPS-Modul and connected in the following way:

GPS -> Arduino:
GND (Pin1) -> GND
VCC(Pin2) -> +5V
TX(Pin3) -> Digital Pin 2
GND (Pin5) -> GND

Here is a pdf to the modul: http://www.dpcav.com/data_sheets/EM411Product_Guide1_2.pdf

Now I wrote a simple code to just see the module working:

#include <SoftwareSerial.h>

SoftwareSerial GPS = SoftwareSerial(2,3);

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

void loop(){
  Serial.write(GPS.read());
}

But something is going wrong. I only get weird characters on my serial output monitor:

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$ÿGÿPÿGÿGÿAÿ,ÿ1ÿ2ÿ0ÿ1ÿ0ÿ1ÿ.ÿ7ÿ2ÿ8ÿ,ÿ,ÿ,ÿ,ÿ,ÿ0ÿ,ÿ0ÿ0ÿ,ÿ,ÿ,ÿMÿ,ÿ0ÿ.ÿ0ÿ,ÿMÿ,ÿ,ÿ0ÿ0ÿ0ÿ0ÿ*ÿ5ÿ8ÿ
ÿ
ÿ$ÿGÿPÿGÿSÿAÿ,ÿAÿ,ÿ1ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ*ÿ1ÿEÿ
ÿ
ÿ$ÿGÿPÿRÿMÿCÿ,ÿ1ÿ2ÿ0ÿ1ÿ0ÿ1ÿ.ÿ7ÿ2ÿ8ÿ,ÿVÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ,ÿ1ÿ6ÿ0ÿ3ÿ1ÿ2ÿ,ÿ,ÿ,ÿNÿ*ÿ4ÿ4ÿ
ÿ
ÿ$ÿGÿPÿVÿTÿGÿ,ÿ,ÿTÿ,ÿ,ÿMÿ,ÿ,ÿNÿ,ÿ,ÿKÿ,ÿNÿ*ÿ2ÿCÿ
ÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$ÿGÿPÿGÿGÿAÿ,ÿ1ÿ2ÿ0ÿ1ÿ0ÿ2ÿ.ÿ7ÿ2ÿ7ÿ,ÿ,ÿ,ÿ,ÿ,ÿ0ÿ,ÿ0ÿ0ÿ,ÿ,ÿ,ÿMÿ,ÿ0ÿ.ÿ0ÿ,ÿMÿ,ÿ,ÿ0ÿ0ÿ0ÿ0ÿ*ÿ5ÿ4ÿ
ÿ

Please help. What am I doing wrong?

Thanks for any help in advance...

Markus

Try Serial.print()/Serial.println() instead of Serial.write().

Thanks for replying, but I tried that before. I only get:

print:

44444478425251131036718086847144448444447744447844447544784250671310-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-13671807171654449505256535346545051444444444448444848444444774448464844774444484848484253691310367180718365446544494444444444444444444444444444444249691310367180827767444950525653534654505144864444444444444449544851495044444478425250131036718086847144448444447744447844447544784250671310-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-13671807171654449505256535446545051444444444448444

println:

4
44
44
44
44
44
49
54
48
51
49
50
44
44
44
78
42
52
56
13
10
36
71
80
86
84
71
44
44
44
77
44
44
75
78
50
13
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-

Any suggestions?

What are you expecting to see?

void loop(){
  Serial.write(GPS.read());
}

You are constantly reading from GPS and writing the result to Serial, regardless of whether there is anything there to be read, which is where all the -1's come from.

That's right but shouldn't I see the NMEA sentences in the output, too?

I saw this on this video:

(deleted)

Serial.write(GPS.read(), BYTE);

Only works pre IDE 1.0.

That's right.

Before IDE 1.0 you had to use print(..., BYTE). After what I have read, with IDE 1.0+ you have to use write().

I thought I had found the error, but it wasn't so. I had to connect a second ground pin to the board.
"GND provides the ground for the engine boards. Be sure to connect all grounds."

Right now I only get -1. That is still strange. I just want to get the NMEA output to the serial monitor on the first step.

Need help, searched the whole internet right now. :frowning:

Markus

Need help, searched the whole internet right now

Yeah, right.

Post the code you have now. Does it include a call to GPS.available()?

It's still use the same code as mentioned above. I tried iGPS.available(), but it's clearly not available. Look at the output.

I checked now every cable and every connection. Everything ok. One cable had some problem, but it's now fixed.

Right now I get the output "-1" all along when using println(...).

I am totally frustrated. I cannot find the problem. I waited long for the module and was looking for getting started with my project.

Markus

It's still use the same code as mentioned above.

Which of the 14 variations?

#include <SoftwareSerial.h>


SoftwareSerial GPS = SoftwareSerial(7,8);

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

void loop(){
  Serial.println(Serial.read());
}
void loop(){
  Serial.println(Serial.read());}

Oh, that's sure to read from the GPS.

Yes, that was complete nonsense. Must have sneaked in while doing try and error. :slight_smile:

I tried now Arduino IDE 0023 with:

#include <SoftwareSerial.h>


SoftwareSerial GPS = SoftwareSerial(7,8);

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

void loop(){
  Serial.print(GPS.read(), BYTE);
}

And voila it works:

$GPGSV,3,3,11,05,06,188,,22,03,334,,12,01,212,*4F
$GPRMC,171055.606,A,5130.6743,N,00706.4511,E,4.57,65.97,160312,,,A*54
$GPVTG,65.97,T,,M,4.57,N,8.5,K,A*3B
$GPGGA,171056.606,5130.6749,N,00706.4522,E,1,04,4.4,28.9,M,47.5,M,,0000*62
$GPGSA,A,3,08,28,17,26,,,,,,,,,5.3,4.4,3.0*37
$GPRMC,171056.606,A,5130.6749,N,00706.4522,E,2.67,89.60,160312,,,A*52
$GPVTG,89.60,T,,M,2.67,N,5.0,K,A*3C
$GPGGA,171057.606,5130.6762,N,00706.4699,E,1,04,4.4,40.2,M,47.5,M,,0000*6C
$GPGSA,A,3,08,28,17,26,,,,,,,,,5.3,4.4,3.0*37
$GPRMC,171057.606,A,5130.6762,N,00706.4699,E,1.47,108.67,160312,,,A*67
$GPVTG,108.67,T,,M,1.47,N,2.7,K,A*02
$GPGGA,171058.605,5130.6761,N,00706.4723,E,1,03,4.6,45.1,M,47.5,M,,0000*60
$GPGSA,A,2,28,17,26,,,,,,,,,,5.6,4.6,3.2*3B
$GPRMC,171058.605,A,5130.6761,N,00706.4723,E,1.80,147.05,160312,,,A*6C
$GPVTG,147.05,T,,M,1.80,N,3.3,K,N*0C
$GPGGA,171059.605,5130.6750,N,00706.4738,E,1,03,4.6,47.7,M,47.5,M,,0000*6D
$GPGSA,A,2,28,17,26,,,,,,,,,,5.6,4.6,3.2*3B
$GPRMC,171059.605,A,5130.6750,N,00706.4738,E,2.36,102.71,160312,,,A*69
$GPVTG,102.71,T,,M,2.36,N,4.4,K,N*00
$GPGGA,171100.605,5130.6747,N,00706.4823,E,1,03,4.6,52.3,M,47.5,M,,0000*63
$GPGSA,A,2,28,17,26,,,,,,,,,,5.6,4.6,3.2*3B
$GPGSV,3,1,11,15,68,279,,27,60,276,,26,58,138,20,28,51,064,20*72
$GPGSV,3,2,11,09,34,268,,18,28,302,,17,22,113,23,08,15,075,*72
$GPGSV,3,3,11,05,06,188,,22,03,334,,12,01,212,*4F
$GPRMC,171100.605,A,5130.6747,N,00706.4823,E,3.27,79.97,160312,,,A*53
$GPVTG,79.97,T,,M,3.27,N,6.0,K,N*32
$GPGGA,171101.605,5130.6755,N,00706.4862,E,1,03,4.6,55.6,M,47.5,M,,0000*66
$GPGSA,A,2,28,17,26,,,,,,,,,,5.6,4.6,3.2*3B
$GPRMC,171101.605,A,5130.6755,N,00706.4862,E,2.08,80.29,160312,,,A*5B
$GPVTG,80.29,T,,M,2.08,N,3.8,K,N*30
$GPGGA,171102.605,5130.6758,N,00706.4875,E,1,03,4.6,58.0,M,47.5,M,,0000*65

Now my question: What is the exact syntax/code I have to use with IDE 1.0?

Markus

What is the exact syntax/code I have to use with IDE 1.0?

So, let's think about this.

The first thing to think about is the return type from GPS.read(). Well, according to SoftwareSerial.h, it returns an int. Now, this is necessary because there is no guarantee that you will call the function correctly (you are not), and that there will always be something to read. If there is nothing to read, the function needs a way to tell you that. It does that by placing valid data in the low order byte of an int, and placing 0 in the low order byte when there is no data. When there is data, the high order byte is 0. When there is no data, the high order byte is not 0.

The result is that the whole value is either -1 if there is no data or the value (in the low order byte) if there was.

So, you could call the function properly, and store the return value in a byte sized variable.

if(GPS.available() > 0)
{
   someType value = GPS.read();
   // Do something with value...
}

OK, so what type should be used? The value that was retrieved from the serial port is 8 bits, so someType could be uint8_t, byte, or char. Which to actually use depends on the kind of data that you expect to get from the device.

In the case of the GPS, it returns ASCII data, so char seems to me to be the base type.

Then, we need to look at sending data to the serial port. There are two overloaded methods that could be used - print() and write(). The behavior of the two methods depends a lot on the type of data that they are being asked to deal with. In general, print() is for converting data to strings and sending them, and for sending strings when the input is already a string. The write() methods are for sending binary data.

Looking at what you are receiving, and want to send, the print() method makes the most sense.

So, the 1.0 code could be:

if(GPS.available() > 0)
{
  char aChar = GPS.read();
  Serial.print(aChar);
}

PaulS, thank you for your help and all detailed and rich instructions. In Germany it's getting late and I have to have some time with my wife, before she is killing me,doing all my time with my project. So I will check your suggestions tomorrow. :))

Again, a big thank you to all helpers here. THANKS!

Markus

hi friend. I need some help, if i must use accelerometer mma7544L and gps EM411 and i wll connect together to arduino. Can you help me give alternate source code to arduino and serial connection use proccessing? tq

if i must use accelerometer mma7544L and gps EM411

Why must you?

i wll connect together to arduino.

How?

Can you help me give alternate source code

Alternate to what? Or did you mean every other letter?

and serial connection use proccessing?

For what? You must have some idea what data you are collecting, and what you are going to do with it in Processing.

Though, I must say, I don't see how an accelerometer and an GPS go together. Are you building a pothole logging application? For what city?