1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OLED付きESP32でTinyGPS++を使う

Last updated at Posted at 2018-07-06

材料

IMG_3659_01.png

ソース


# 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カードに書き出すとかお好みで。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?