🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Which Serial is Port.C on the M5Paper?

    Arduino
    1
    2
    252
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      frank_b
      last edited by

      hello,

      like to use the m5paper port.c to serial read a gps. cannot seem to find which serial port is port.c. Serial is USB-C port, so is it Serial1? documentation only mentions g18/g19...

      thanks
      frank

      F 1 Reply Last reply Reply Quote 0
      • F
        frank_b @frank_b
        last edited by

        answering my own question:

        #include <M5EPD.h>
        #include <TinyGPS++.h>
        
          static const uint32_t GPSBaud = 9600;
        
        TinyGPSPlus gps;
        HardwareSerial ss(2);
        
        M5EPD_Canvas canvas(&M5.EPD);
        
        char latStr[10];
        char lonStr[10];
        char speedStr[10];
        
        void setup() {
        
          M5.begin();
          M5.EPD.SetRotation(0);
          M5.EPD.Clear(true);
        
          ss.begin(GPSBaud, SERIAL_8N1, 19, 18);
        
          canvas.createCanvas(960, 540);
          canvas.setTextSize(3);
          canvas.clear();
        }
        
        void loop() {
        
          int b = ss.available();
        
          while (b > 0) {
        
            gps.encode(ss.read());
        
            double lat = gps.location.lat();
            double lon = gps.location.lng();
            double speed = gps.speed.kmph();
        
            dtostrf(lat, 2, 2, latStr);
            dtostrf(lon, 2, 2, lonStr);
            dtostrf(speed, 2, 2, speedStr);
        
            canvas.clear();
            canvas.drawString("Lat:   " + String(latStr), 50, 100);
            canvas.drawString("Lon:   " + String(lonStr), 50, 150);
            canvas.drawString("Speed: " + String(speedStr), 50, 200);
            canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
          }
        }
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post