today i write some small firmware to test the module if it works as intended. firstly i just make it get the GPS signal and display my location on my PC:
#include<stdio.h>
#include<string.h>
#define DEBUG true
int pon=9;
int poff=6;
int lowp=5;
#include<stdio.h>
#include<string.h>
#define DEBUG true
int pon=9;
int poff=6;
int lowp=5;
void setup()
{
pinMode(pon, OUTPUT);
pinMode(poff, OUTPUT);
pinMode(lowp, OUTPUT);
digitalWrite(poff, LOW);
digitalWrite(lowp, HIGH);
digitalWrite(pon, HIGH);
SerialUSB.begin(115200);
while (!SerialUSB) {
; // wait for serial port to connect
}
Serial1.begin(115200);
digitalWrite(pon, LOW);
delay(3000);
digitalWrite(pon, HIGH);
delay(5000);
sendData("AT+GPS=1 ",1000,DEBUG);
}
void loop()
{
sendData("AT+GPSRD=1",1000,DEBUG);
delay(1000);
}
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
Serial1.println(command);
long int time = millis();
while( (time+timeout) > millis())
{
while(Serial1.available())
{
char c = Serial1.read();
response+=c;
}
}
if(debug)
{
SerialUSB.print(response);
}
return response;
}
in 30 seconds, it output as:
it means:
The UTC time: 035442;
The valid location: A,means yes
And my location: 2235.5484, Northern Hemisphere and 11351.4722, East longitude;
and follows some charators, i do not quite understand, and care;
and date: 070618(date/month/year)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.