GPS

I can't get a readout from my gps-module.

I connected the GPS to an arduino uno and nano without any change in the result

GPSmodule
rx tx gnd vcc
I I I I
tx rc gnd 5v
(1) (0)
#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*=' ';*

  • } *
    }
    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.print(byteGPS, BYTE);*
  • if (byteGPS==13){ // If the received byte is = to 13, end of transmission*
  • // note: the actual end of transmission is (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 (0x10) from the previous transmission.*
  • for (int i=1;i<7;i++){ // Verifies if the received command starts with $GPR*
    _ if (linea*==comandoGPR[i-1]){_
    _
    bien++;_
    _
    }_
    _
    }_
    _
    if(bien==6){ // If yes, continue and process the data*_
    * for (int i=0;i<300;i++){*
    _ if (linea*==','){ // check for the position of the "," separator*
    * // note: again, there is a potential buffer overflow here!
    indices[cont]=i;
    cont++;
    }
    if (linea==''){ // ... 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;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=' ';
    }
    }
    }
    }*

    the code i use is_

. . . and that why we need you to use code tags.

Please edit your post to add them.

How do you expect to send data to the PC on Serial and also get data from the GPS on the same line?

Are you sure the GPS is 4800 baud?

Do not cross-post. Threads merged and trimmed.

I'm totaly new to arduino so forgive me for the beginners mistakes I will make.

I've made some changes to the code.

The set up is an arduino Uno, With an lcd shield on top from DFRobot. The Gps-module gets power from the lcd shield and is connected to the digital poorts 2 and 3 of the UNO.

I only get the text below on the screen, but no gpsposition.

"Lat: 0.000000
Long: 0.000000"

// initialising the libraries
#include <TinyGPS.h>;
#include <SoftwareSerial.h>;
#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
unsigned long fix_age;

SoftwareSerial GPS(2,3); // asing the pins/ports that receive the gps data
TinyGPS gps;
void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();
long lat, lon;
float LAT, LON;

void setup(){
 GPS.begin(9600); // setting the data-rate
 lcd.begin(16, 2);  //setting the dimentions of the lcd
}

void loop(){
 long lat, lon;
 unsigned long fix_age, time, date, speed, course;
 unsigned long chars;
 unsigned short sentences, failed_checksum;


 // retrieves +/- lat/long in 100000ths of a degree
 gps.get_position(&lat, &lon, &fix_age);

 //prints the data on the lcd or should I use serial.println?
 getGPS();
 lcd.setCursor(0, 0);
 lcd.print("Lat:  ");
 lcd.print(LAT/100000,7);
 lcd.setCursor(0, 1);
 lcd.print("Long: ");
 lcd.print(LON/100000,7);
}


// getting the actual gps data 
void getGPS(){
 bool newdata = false;
 unsigned long start = millis();
 // Every 1 seconds we print an update
 while (millis() - start < 1000)
 {
   if (feedgps ()){
     newdata = true;
   }
 }
 if (newdata)
 {
   gpsdump(gps);
 }
}

bool feedgps(){
 while (GPS.available())
 {
   if (gps.encode(GPS.read()))
     return true;
 }
 return 0;
}

void gpsdump(TinyGPS &gps)
{
 //byte month, day, hour, minute, second, hundredths;
 gps.get_position(&lat, &lon);
 LAT = lat;
 LON = lon;
 {
   feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors
 }
}

CODE TAGS

Read this, step 7!