- 12V Akku mit 280 Ah bauen         
Ergebnis 1 bis 7 von 7

Thema: Arduino soll GPS Daten auswerten

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #3
    Benutzer Stammmitglied
    Registriert seit
    09.02.2013
    Beiträge
    51
    Ich habe das SainSmart LCD Keypad Shield, das läuft wie oben im Script dargestellt ist.
    Mit geht's wirklich nur um die Auswertung des GPS strings der per UART ankommt. Wie schließe ich ihn an, wie lese und werte ich ihn aus.

    Quelle:
    http://playground.arduino.cc/Tutorials/GPS

    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(38400);
       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]=' ';             
           }                 
         }
       }
     }

    Dieser Script läuft. Ich bin nur nicht in der Lage die Daten auf meinem Display anzuzeigen^^
    LG
    Geändert von Spacecam (21.01.2014 um 16:13 Uhr)

Ähnliche Themen

  1. Habe Arduino Uno,GPS Modul,RC Auto.Möchte haben:Auto,dass GPS Waypoints abfährt
    Von de8msharduino im Forum Allgemeines zum Thema Roboter / Modellbau
    Antworten: 9
    Letzter Beitrag: 07.10.2011, 21:53
  2. NMEA von GPS-Modul auswerten
    Von JeyBee im Forum C - Programmierung (GCC u.a.)
    Antworten: 14
    Letzter Beitrag: 06.02.2010, 08:40
  3. GPS Empfänger selber auswerten
    Von runner02 im Forum Elektronik
    Antworten: 2
    Letzter Beitrag: 28.05.2008, 20:21
  4. gps datensätze auswerten wie macht ihr das
    Von yak im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 13
    Letzter Beitrag: 02.10.2007, 20:29
  5. Ein GPS-Tracker zum Abruf von GPS-Daten via GSM
    Von gpsklaus im Forum Vorstellungen+Bilder von fertigen Projekten/Bots
    Antworten: 2
    Letzter Beitrag: 06.09.2006, 14:24

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

12V Akku bauen