UART - 检索 GPS 位置
材料准备
AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1
Adafruit Ultimate GPS Breakout x 1 (可参考 官方文件))
范例说明
这边介绍使用Adafruit Ultimate GPS Breakout。它的资料格式是文字介面,所以可以直接接在USB to TTL Adapter上直接看GPS内容:
的格式使用NMEA sentence, 详细内容可以参考http://aprs.gids.nl/nmea/ 但在室内不太容易收到GPS讯号,上一张图尚未收到讯号,称之为还没“fix”。带GPS模组到室外做测试,等到fix有讯号的内容长的像这样:
In this example we are only interested in the “$GPRMC (Global Positioning Recommended Minimum Coordinates)”: $GPRMC,032122.000,A,2446.8181,N,12059.7251,E,0.39,78.89,270116,,,A*53 Each field is separated by a comma.
第1栏是GMT(Greenwich Mean Time), 这边的例子是032122.000, 格式为HH:MM:SS.SSS, 也就是03:21:22.000。时区与日光节约需要自行调整
第2栏是status code
V: Void (Invalid)
A: Active, 这个状态下GPS可以fix
3~6栏是地理位置定位(geolocation)
例子中,2446.8181,N 表示北半球纬度24度46.8181分,12059.7251,E 表示东半球经度120度59.7251分,
我们可以在google map的搜寻栏输入+24 46.8181′, +120 59.7251′ 就可以检查位置是否正确
AMB21 / AMB22 接线图如下:
AMB23 接线图如下:
BW16 Wiring Diagram:
BW16-TypeC Wiring Diagram:
Open the example in “Files” → “Examples” →
“AmebaSoftwareSerial” → “Adafruit_GPS_parsing”
.
Compile and upload to Ameba, then press the reset button. The result will be output to Serial Monitor: