I have this GPS
em-406a gps module
this is the datasheet of it -
can I connect him to the Arduino and read the position from him?
so I will get for example
Latitude : 43.626931 | Longitude : -79.438705?
Thanks,
I have this GPS
em-406a gps module
this is the datasheet of it -
can I connect him to the Arduino and read the position from him?
so I will get for example
Latitude : 43.626931 | Longitude : -79.438705?
Thanks,
(deleted)
Thanks for the answer
is this code can help me? and work for me?
http://playground.arduino.cc/Tutorials/GPS
or I need to find\write a code that work on serial gps?
Thanks ,
is this code can help me?
Try it and see. You will need to connect RX on the Arduino to TX on the GPS module, and also connect the module and Arduino grounds together. The monitor will need to be set at 4800 baud.
doesn't work
I don't get any data in serial monitor
are you sure this is who I need to connect it?
I have also try to replace Tx with Rx
I have try this simple code (just to see if I get anything )-and I do
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8);
void setup()
{
Serial.begin(4800);
mySerial.begin(4800);
}
void loop()
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
and this is what I get
$GPGGA,122215.072,,,,,0,00,,,M,0.0,M,,0000*54
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,122215.072,V,,,,,,,260814,,*24
$GPGGA,122216.075,,,,,0,00,,,M,0.0,M,,0000*50
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,122216.075,V,,,,,,,260814,,*20
$GPGGA,122217.074,,,,,0,00,,,M,0.0,M,,0000*50
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,122217.074,V,,,,,,,260814,,*20
$GPGGA,122218.069,,,,,0,00,,,M,0.0,M,,0000*53
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,122218.069,V,,,,,,,260814,,*23
$GPGGA,122219.069,,,,,0,00,,,M,0.0,M,,0000*52
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,20,00,000,,10,00,000,,25,00,000,,27,00,000,*79
$GPGSV,3,2,12,22,00,000,,07,00,000,,21,00,000,,24,00,000,*79
$GPGSV,3,3,12,16,00,000,,28,00,000,,26,00,000,,29,00,000,*78
$GPRMC,122219.069,V,,,,,,,260814,,*22
$GPGGA,122220.079,,,,,0,00,,,M,0.0,M,,0000*59
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
now I want\need to know how do I get the coordinates and my GPS position from this
Thanks ,
first you need to parse the GPS data,
U need to keep in open space to get full data. You can find still data is not accumulated.
Here i am attaching code for reference where data has been already stripped.
main_c.rar (1.5 KB)
Take a look at the tinygps library - it will handle the parsing for you.
Thanks ,
I have took you code and try to run it
but I don't get real data
this is what I get
0/
0latitude:
1000.00longitude:
1000.00
2000/
0/
0latitude:
1000.00longitude:
1000.00
2000/
0/
0latitude:
1000.00longitude:
1000.00
2000/
0/
like it doesn't connect
I thought maybe I misplace the Tx and Rx - but I get the same response .
I can see the GPS is connected and working because it blinks ,and in it datasheet is said
LED Flashing: Position Fixed
so what could be the problem ?
I have now found another program that does work :
#include "TinyGPS.h"
#include "SoftwareSerial.h"
#define HEMISPHERE_PIN 13
#define GPS_RX_PIN 8
#define GPS_TX_PIN 7
TinyGPS gps; // create a TinyGPS object
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN); // create soft serial object
void setup()
{
Serial.begin(9600); // for debugging
ss.begin(4800); // Use Soft Serial object to talk to GPS
pinMode(HEMISPHERE_PIN, OUTPUT);
digitalWrite(HEMISPHERE_PIN, LOW); // turn off LED to start
}
void loop()
{
while (ss.available())
{
int c = ss.read();
Serial.write(c); // display NMEA data for debug
// Send each byte to encode()
// Check for new position if encode() returns "True"
if (gps.encode(c))
{
long lat, lon;
unsigned long fix_age;
gps.get_position(&lat, &lon, &fix_age);
if (fix_age == TinyGPS::GPS_INVALID_AGE )
Serial.println("No fix ever detected!");
else if (fix_age > 2000)
Serial.println("Data is getting STALE!");
else
Serial.println("Latitude and longitude valid!");
Serial.print("Lat: ");
Serial.print(lat);
Serial.print(" Lon: ");
Serial.println(lon);
if (lat < 0) // Southern Hemisphere?
digitalWrite(HEMISPHERE_PIN, HIGH);
else
digitalWrite(HEMISPHERE_PIN, LOW);
}
}
}
I can get a real coordinate - but I get them as a long number
Lat: 32089260 Lon: 34858265
how can I change it to make this work in google maps (for example)
I need it to be
32.089260 34.858265
I have try to make
float LON=lon/1000000;
but I get only 2 numbers after the "."
how do I get at least 4 ? (for better position)
Thanks ,
how do I get at least 4 ? (for better position)
serial.Print(LonF,4); // assuming LonF is a float
didn't know that
Thanks !
don't get mad - I have try it .
and he didn't work
I didn't get any response from the GPS
and you didn't answer me about it - what to do , so I have search another solution.
but let try your code again
I have connected to pin 8,9 and I still get the same answer
0/
0latitude:
1000.00longitude:
1000.00
2000/
0/
0latitude:
1000.00longitude:
1000.00
2000/
0/
so tell me what do you think? where is the problem?
I have also change in gps_C
this line SoftwareSerial ss(7,8);
and try to connect the GPS to PIN7&8
still getting the same answer
so what is wrong?
(and we know the GPS is working with another code)
Thanks ,
Back in Reply #5 you said "This is what I get...". The only reason you weren't seeing your location is because you hadn't got a satellite lock at that point. If you wait, and it has a clear view of the sky, it will eventually lock on and you will see your location in the data on screen.
I do have a satellite lock
because if I upload now the second function - I do see coordinates
(I leave it at the same place )
so I don't think this is the problem
In the data you displayed you did not have a satellite lock. It tells you that in the data. Have you looked up the meaning of the the various NMEA codes? $GPGGA tells you the fix quality, and when you do get a lock, your location.
I get an error
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.
so I have wrote
Serial.write(byteGPS)
and not
Serial.print(byteGPS, BYTE);
this is what I get
Time in UTC (HhMmSs): 081950.000
Status (A=OK,V=KO): A
Latitude: 3205.3578
Direction (N/S): N
Longitude: 03451.4954
Direction (E/W): E
Velocity in knots: 0.62
Heading in degrees: 137.35
Date UTC (DdMmAa): 270814
Magnetic degrees:
(E/W):
Mode: $GPRMC,081950.000,A,3205.3578,N,03451.4954,E,0.62,137.35,270814,,
---------------
$GPGGA,081951.000,3205.3577,N,03451.4955,E,1,05,1.9,60.8,M,17.0*60
$GPGSA,A,3,12,24,29,06,02,,,,,,,,3.3,1.9,2.7*35
$GPGSV,3,1,10,12,62,014,30,24,59,182,40,02,56,084,21,25,40,318,21*7A
$GPGSV,3,2,10,29,30,251,31,06,28,048,30,14,15,289,,10,04,088,26*75
$GPGSV,3,3,10,05,04,134,42,15,00,190,*75
$GPRMC,081951.000,A,3205.3577,N,03451.4955,E,0.47,141.88,270814,,*04
While uploading disconnect your rx and tx pins.
Here i am attaching code . and image where i got compiled successfully. I dont have GPS device at present to show you output.
Once code uploaded successfully. connect TX and Rx pins as mentioned in program.
int rxPin = 0; // RX PIN
int txPin = 1; // TX TX
then print screen and share snap shot of serial monitor
FLOAT_STORE.rar (1.49 KB)
Are you near Tel-Aviv?
this is the code
#include <string.h>
#include <ctype.h>
int ledPin = 13; // LED test pin
int rxPin = 0; // RX PIN
int txPin = 1; // TX TX
int byteGPS=-1;
char linea[300] = "";
char comandoGPR[7] = "$GPRMC";
int cont=0;
int bien=0;
int conta=0;
int indices[13];
void setup() {
pinMode(ledPin, OUTPUT); // Initialize LED pin
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
Serial.begin(4800);
for (int i=0;i<300;i++){ // Initialize a buffer for received data
linea[i]=' ';
}
}
void loop() {
digitalWrite(ledPin, HIGH);
byteGPS=Serial.read(); // Read a byte of the serial port
if (byteGPS == -1) { // See if the port is empty yet
delay(100);
} else {
// note: there is a potential buffer overflow here!
linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer
conta++;
Serial.write(byteGPS);
if (byteGPS==13){ // If the received byte is = to 13, end of transmission
// note: the actual end of transmission is <CR><LF> (i.e. 0x13 0x10)
digitalWrite(ledPin, LOW);
cont=0;
bien=0;
// The following for loop starts at 1, because this code is clowny and the first byte is the <LF> (0x10) from the previous transmission.
for (int i=1;i<7;i++){ // Verifies if the received command starts with $GPR
if (linea[i]==comandoGPR[i-1]){
bien++;
}
}
if(bien==6){ // If yes, continue and process the data
for (int i=0;i<300;i++){
if (linea[i]==','){ // check for the position of the "," separator
// note: again, there is a potential buffer overflow here!
indices[cont]=i;
cont++;
}
if (linea[i]=='*'){ // ... and the "*"
indices[12]=i;
cont++;
}
}
Serial.println(""); // ... and write to the serial port
Serial.println("");
Serial.println("---------------");
for (int i=0;i<12;i++){
switch(i){
case 0 :Serial.print("Time in UTC (HhMmSs): ");break;
case 1 :Serial.print("Status (A=OK,V=KO): ");break;
case 2 :Serial.print("Latitude: ");break;
case 3 :Serial.print("Direction (N/S): ");break;
case 4 :Serial.print("Longitude: ");break;
case 5 :Serial.print("Direction (E/W): ");break;
case 6 :Serial.print("Velocity in knots: ");break;
case 7 :Serial.print("Heading in degrees: ");break;
case 8 :Serial.print("Date UTC (DdMmAa): ");break;
case 9 :Serial.print("Magnetic degrees: ");break;
case 10 :Serial.print("(E/W): ");break;
case 11 :Serial.print("Mode: ");break;
case 12 :Serial.print("Checksum: ");break;
}
for (int j=indices[i];j<(indices[i+1]-1);j++){
Serial.print(linea[j+1]);
}
Serial.println("");
}
Serial.println("---------------");
}
conta=0; // Reset the buffer
for (int i=0;i<300;i++){ //
linea[i]=' ';
}
}
}
}
I have added the serial monitor
also the coordinates are correct
now what to do?
try the first code you gave me?
Thanks,
Ya , Now code is working fine . upload my code With changes made intailly . share me snap shot of serial monitor. Change Serial monitor output loop. I have not changed.
change it
from
#include<gps.h>
To
#include"gps.h"
and include in main_c and gps_c.ino file
main_c.rar (1.51 KB)
I get an error
In file included from main_c.ino:4:
gps.h:16: error: expected initializer before 'gpsTimeToArduinoTime'
gps.h:17: error: expected initializer before 'gpsTimeSync'