步驟1:電路連接
RED線(xiàn)到Ultimate板的5V連接
BLUE線(xiàn)到Ultimate板的RxD連接
GREEN線(xiàn)到Ultimate板的TxD連接
WHITE線(xiàn)到Ultimate板的PPS連接
根據(jù)我們的代碼
connect
RXPin電路板到digitalPin 4,
電路板到digitalPin 3的TXPin
Vcc到5v,GND到GND
步驟2:編程
首先需要一個(gè)庫(kù):
您可以從此處下載
在arduino中安裝庫(kù)之后,打開(kāi) DeviceExample.ino 來(lái)自示例》 tinyGPS ++
或簡(jiǎn)單地復(fù)制以下代碼。
#include
#include
/*
* https://alaspuresujay.github.io/
* follow me on instagram https://www.instagram.com/alaspuresujay
*
This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and assumes that you have a
9600-baud serial GPS device hooked up on pins 4(rx) and 3(tx)。
*/
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
Serial.println(F(“DeviceExample.ino”));
Serial.println(F(“A simple demonstration of TinyGPS++ with an attached GPS module”));
Serial.print(F(“Testing TinyGPS++ library v. ”)); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F(“by Sujay Alaspure”));
Serial.println();
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() 》 0)
if (gps.encode(ss.read()))
displayInfo();
if (millis() 》 5000 && gps.charsProcessed() 《 10)
{
Serial.println(F(“No GPS detected: check wiring.”));
while(true);
}
}
void displayInfo()
{
float latt=gps.location.lat();
Serial.print(gps.location.lat(),10);
Serial.print(F(“,”));
Serial.print(gps.location.lng(), 10);
Serial.print(“ ”);
Serial.print(latt,10);
Serial.print(F(“Location: ”));
if (gps.location.isValid())
{
Serial.print(gps.location.lat(), 6);
Serial.print(F(“,”));
Serial.print(gps.location.lng(), 6);
}
else
{
Serial.print(F(“INVALID”));
}
Serial.print(F(“ Date/Time: ”));
if (gps.date.isValid())
{
Serial.print(gps.date.month());
Serial.print(F(“/”));
Serial.print(gps.date.day());
Serial.print(F(“/”));
Serial.print(gps.date.year());
}
else
{
Serial.print(F(“INVALID”));
}
Serial.print(F(“ ”));
if (gps.time.isValid())
{
if (gps.time.hour() 《 10) Serial.print(F(“0”));
Serial.print(gps.time.hour());
Serial.print(F(“:”));
if (gps.time.minute() 《 10) Serial.print(F(“0”));
Serial.print(gps.time.minute());
Serial.print(F(“:”));
if (gps.time.second() 《 10) Serial.print(F(“0”));
Serial.print(gps.time.second());
Serial.print(F(“?!保?
if (gps.time.centisecond() 《 10) Serial.print(F(“0”));
Serial.print(gps.time.centisecond());
}
else
{
Serial.print(F(“INVALID”));
}
Serial.println();
}
步驟3:注意:
請(qǐng)將GPS模塊放在房屋外面或窗戶(hù)旁邊。
廉價(jià)的GPS模塊例如VK16E的1pps信號(hào)精度不高。
您可能會(huì)發(fā)現(xiàn),與許多使用貼片天線(xiàn)的GPS模塊一樣,GPS模塊可能需要放在窗戶(hù)旁邊或外面。 GPS信號(hào)的強(qiáng)度似乎會(huì)根據(jù)位置和周?chē)ㄖ锏鹊牟煌泻艽蟛町?。根?jù)您的棚屋布局和接地情況,離極限套件越遠(yuǎn),GPS模塊也可能會(huì)受益。因此,您可能需要使用幾米長(zhǎng)的電線(xiàn)將GPS模塊連接到套件。我建議在屏幕連接到Gnd的情況下使用屏蔽電纜。 4)
該模塊具有綠色LED(如上圖所示),在GPS模塊搜索衛(wèi)星鎖定時(shí)該LED持續(xù)亮起,并且在鎖定時(shí)以每秒1脈沖的頻率閃爍。/strong》
責(zé)任編輯:wv
-
GPS模塊
+關(guān)注
關(guān)注
0文章
87瀏覽量
16436 -
Arduino
+關(guān)注
關(guān)注
188文章
6468瀏覽量
186952
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論