NEO-6M GPS shield#
实物图#
GPS记录 扩展板 GPS 模块 带SD卡槽 +天线
此模块可用于练习 GPS 数据的解析,UART 接收, SPI SD 使用,实时时钟等
注意事项#
Shield 上的串口并没有固定连接到 D0 和D1, 而是需要用跳线帽在 D1~D7 中选择。
这个是最接近的 GPS 扩展板。
文档#
此模块有部分资料,待整理上传
文档与源码: guide @ google, 但是打不开 Google 啊!
下面的文档能打开:
Ks0253 keyestudio GPS Shield - Keyestudio Wiki
连线
D10: SPI_CS for SD Card
D13~D11: SPI Wire
D6: UART RX
D7: UART TX
代码#
/*
Demo code for GPS Shield
It records the GPS information onto the TF card,
and display on serial monitor as well.
http://makerstudio.cc
*/
#include <SD.h>
#include <SPI.h>
#include <SoftwareSerial.h>
const int chipSelect = 10;
SoftwareSerial mySerial(6,7);//(RX,TX), (6->GPS_TX,7->GPS_RX)
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
pinMode(10, OUTPUT);
if (!SD.begin(chipSelect)) {
return;
}
}
void loop()
{
// make a string for assembling the data to log:
char index = 0;
char temp = 0;
String dataString = "";
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if(dataFile)
{
while(mySerial.available())
{
temp = mySerial.read();
Serial.print(temp);
dataString += String(temp);
index++;
if(index>200)
break;
}
dataFile.print(dataString);
dataFile.close();
}else
{
Serial.println("Open file failed");
}
}