我無法使用TinyGPS庫來分析Lat和Lon。這個庫與RFduino兼容嗎?我可以通過加載一個空白的草圖到RFduino然後打開串行監視器來讀取NMEA字符串,所以我知道GPS數據正在通過串行端口,但是當我嘗試將Lat或Lon變成變量時,它用999999999填充變量。我通過BLE將這些數據發送給一個android。如果我不嘗試獲取GPS數據,則可以在經緯度或垂直變量中發送我想要的任何值,並將其顯示在我的自定義Android應用程序中。我在某處讀到softserial庫不適用於rfduino。這是真的?如果沒有,我將能夠通過硬串行端口打印我的數據,從而使故障排除變得更加容易。下面我附上了我在RFduino上使用的代碼。任何意見,將不勝感激。RFduino不從GPS拉NMEA字符串
// CODE //
#include <RFduinoBLE.h>
#include <TinyGPS.h>
TinyGPS gps;
long lat = 5; //Load lat/lon with junk value for testing
long lon = 6;
char latBuf[20];
char lonBuf[20];
void setup() {
// this is the data we want to appear in the advertisement
// (if the deviceName and advertisementData are too long to fix into the 31 byte
// ble advertisement packet, then the advertisementData is truncated first down to
// a single byte, then it will truncate the deviceName)
RFduinoBLE.advertisementData = "ledbtn";
// start the BLE stack
RFduinoBLE.begin();
Serial.begin(9600);//For GPS Communication
}
void loop(){
char c = byte(Serial.read());
gps.encode(c);
gps.get_position(&lat,&lon); // get latitude and longitude
// send position as char[]
String latString = String(lat);
String lonString = String(lon);
latString.toCharArray(latBuf, 20);
lonString.toCharArray(lonBuf, 20);
RFduinoBLE.send(lonBuf, 20);
}
void RFduinoBLE_onDisconnect()
{
}
void RFduinoBLE_onReceive(char *data, int len)
{
RFduinoBLE.send(lonBuf, 20);
}
你是怎麼設法使用rfduino的gps模塊和哪個模塊的? – quape
我使用了這個模塊。 http://www.adafruit.com/products/790 – user1359770