材料
ソース
# include <TinyGPS++.h>
# include "SSD1306.h"
SSD1306 display(0x3c, 5, 4);
TinyGPSPlus gps;
void setup() {
Serial.begin(19200);
Serial.print("Start!");Serial.println("");
/* Wemos OLED setup
*/
display.init();
display.flipScreenVertically();
display.displayOn();
display.clear();
display.drawString(0, 32, "Hello");
display.display();
delay(100);
}
void loop() {
while (Serial.available() > 0){
if (gps.encode(Serial.read())){
/* Output Serial
*/
Serial.print("LAT=");Serial.println(gps.location.lat(),6);
Serial.print("lng=");Serial.println(gps.location.lng(),6);
Serial.print("ALT=");Serial.println(gps.altitude.meters());
Serial.print("sate=");Serial.println(gps.satellites.value());
/* dtostrf
*/
char gpslat[16],gpslng[16],gpshigh[16],gpssate[16];
dtostrf(gps.location.lat(), 12, 8, gpslat);
dtostrf(gps.location.lng(), 12, 8, gpslng);
dtostrf(gps.altitude.meters(), 12, 4, gpshigh);
dtostrf(gps.satellites.value(), 12, 0, gpssate);
/* Output Wemos OLED
*/
display.clear();
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 0, "GPS");
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_RIGHT);
display.drawString(127,0,gpslat);
display.drawString(127,16,gpslng);
display.drawString(127,32,gpshigh);
display.drawString(127,48,gpssate);
display.display();
}
}
}
メモ
WiFiライブラリ入れてAmbientとかのクラウドに送るとか、SDカードに書き出すとかお好みで。