Buenas gente! antes de nada agradecer a toda la comunidad por la ayuda que me estan dando en estos inicios con arduino.
Tengo dudas con el modulo GPS para arduino, la cosa esta instalada y funciona perfectamente. Este es el sketch que estoy utilizando:
/*******************************************
* Program for reading possition from GPS
* module via the softwareSerial
*
* M. Yarza
* Oct 2.007 Zaragoza
*******************************************/
// include the SoftwareSerial library
#include <SoftwareSerial.h>
// Constants
#define rxPin 9NMEA
#define txPin 8
// set up the serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
// variables
byte byteGPS = 0;
int i = 0;
int indices[13];
int cont = 0;
int conta = 0;
char inBuffer[300] = "";
int k = 0;
void setup(){
//setup for mySerial port
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(4800);
//setup for Serial port
Serial.begin(19200);
// setup the GPS module en la posicion de loteria 2, Bilbao
Serial.println("Configurando GPS...");
delay(1000);
mySerial.println("$PSTMNMEACONFIG,0,4800,1,1"); // configure NMEA sentences to show only GGA sentence
delay(100);
// command for setting time and position
mySerial.println("$PSTMINITGPS,4315.280,N,0255.267,W,0016.0,24,01,2008,17,15,00");
// "4140.000,N" means: Latitude 41º40'00.0" North
// "00053.000,W" means: Longitude 0º53'00.0" West
// "0197" means 197 m elevation
// "22,10,2007,11,40,00" means date and time (October 22, 2.007 - 11h 40min 00sec UTC time)
}
void loop(){
byteGPS = 0;
i = 0;
while(byteGPS != 42){ // read the GGA sentence
byteGPS = mySerial.read();
inBuffer[i]=byteGPS;
i++;
}
k = 0;
while(inBuffer[k] != 42){
Serial.print(inBuffer[k]); // write the GGA sentence
k++;
}
Serial.println();
delay(3000);
}
El aparato funciona y leo con el Serial monitor y envia bien la informacion. El problema que tengo es que luego a la hora de utilizar estos datos desde otro entorno (estoy utilizando python y el modulo gps de python, tambien he echo pruebas con otros interfaces) no leo bien los datos.
Utilizo linux con el gspd para leer valores del protocolo NMEA pero en algo debo de fallar porque no toma los valores. Y el caso es que si hay comunicacion serie entre ellos. Pego aqui el codigo python con el que leo los datos:
import gps, os, time
session = gps.gps()
while 1:
os.system('clear')
session.query('admosy')
# a = altitude, d = date/time, m=mode,
# o=postion/fix, s=status, y=satellites
print
print ' GPS reading'
print '----------------------------------------'
print 'latitude ' , session.fix.latitude
print 'longitude ' , session.fix.longitude
print 'time utc ' , session.utc, session.fix.time
print 'altitude ' , session.fix.altitude
print 'eph ' , session.fix.eph
print 'epv ' , session.fix.epv
print 'ept ' , session.fix.ept
print 'speed ' , session.fix.speed
print 'climb ' , session.fix.climb
print
print ' Satellites (total of', len(session.satellites) , ' in view)'
for i in session.satellites:
print '\t', i
time.sleep(3)
Como veis el codigo es sencillo, pero no me devuelve los valores del modulo gps que veo en el serial monitor