Ch4_4. GPS모듈 연결하여 위치좌표 구하기
학습 내용
GlobalSat EM-406 GPS모듈을 mbed에 연결하여 위치좌표를 시리얼통신을 통해 PC에 나타내는 학습을 합니다
배선도 & 회로도
- VCC :5v
- Tx :mbed serial rx (e.g. p10)
- Rx :mbed serial tx (e.g. p9)
- GND :0v/GND
배선 사진
코딩
#include "mbed.h" #include "GPS.h" Serial pc(USBTX, USBRX); GPS gps(p9, p10); int main() { while(1) { if(gps.sample()) { pc.printf("I'm at %f, %f\n", gps.longitude, gps.latitude); } else { pc.printf("Oh Dear! No lock :(\n"); } } }
라이브러리
- EM-406 GPS Library
Import library
Public Member Functions
GPS (PinName tx, PinName rx) Create the GPS interface, connected to the specified serial port.
int sample () Sample the incoming GPS data, returning whether there is a lock.
Data Fields
float longitude The longitude (call sample() to set)
float latitude The latitude (call sample() to set)
학습 참고
1 comment on Ch4_4. GPS모듈 연결하여 위치좌표 구하기:
Please log in to post comments.
include the mbed library with this snippet
I tried this code with a GTPA010 GPS module. Code runs, with no compiling error. But I am getting no output at all. The GPS blinks continuously.
If the GPS couldnt find the NMEA string, according to the code, mbed should atleast say "Oh Dear! No lock :( " in the Tera Term but I dont receive any serial output.
I checked 4800, 9600, 38400 baud rates. No improvements.
Although, I see a strange thing happening. All the Leds in the mbed board starts blinking after 15 - 20 mins.
Please provide suggestions.
- Thanks, Abhilash