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

    m5dial uart

    Scheduled Pinned Locked Moved General
    1 Posts 1 Posters 920 Views 1 Watching
    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.
    • J Offline
      jappielat
      last edited by

      Hello to you all,

      I have recently started a project where i want to create a compass that points to a certain location using a gps and qmc sensor. For this im using the m5 dial as the controller with the qmc5883l and the gravity gnss module for the location of the device. The qmc sensor is used over i2c so on port A of the m5 dial. Now im trying to use uart on port B to communicate witht the gnss module, but i cant get this to work. I have taken the code directly from the site of the gnss module and changed the pins, but i continuously get the message no device. Can you guys help me with this?
      The code i uploaded:

      /*!
        * @file  getGNSS.ino
        * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
        * @license The MIT License (MIT)
        * @author ZhixinLiu(zhixin.liu@dfrobot.com)
        * @version V0.1
        * @date 2022-08-15
        * @url https://github.com/dfrobot/DFRobot_GNSS
        */
      
      #include "DFRobot_GNSS.h"
      
      HardwareSerial Serial3(1); // Use UART1 for GNSS communication
      DFRobot_GNSS_UART gnss(&Serial3, 9600);
      
      void setup() 
      {
        Serial.begin(115200); // Initialize serial monitor
        Serial3.begin(9600, SERIAL_8N1, 1, 2); // Initialize UART1 with RX=1, TX=2
      
        while(!gnss.begin()){
          Serial.println("NO Devices!");
          delay(1000);
        }
      
        gnss.enablePower();      
      
        /** Set the galaxy to be used
         *   eGPS              USE gps
         *   eBeiDou           USE beidou
         *   eGPS_BeiDou       USE gps + beidou
         *   eGLONASS          USE glonass
         *   eGPS_GLONASS      USE gps + glonass
         *   eBeiDou_GLONASS   USE beidou + glonass
         *   eGPS_BeiDou_GLONASS USE gps + beidou + glonass
         */
        gnss.setGnss(eGPS_BeiDou_GLONASS);
      
        // Optional: Enable or disable RGB indicator on GNSS module
        // gnss.setRgbOff();
        gnss.setRgbOn();
        // gnss.disablePower();      
      }
      
      void loop()
      {
        sTim_t utc = gnss.getUTC();
        sTim_t date = gnss.getDate();
        sLonLat_t lat = gnss.getLat();
        sLonLat_t lon = gnss.getLon();
        double high = gnss.getAlt();
        uint8_t starUsed = gnss.getNumSatUsed();
        double sog = gnss.getSog();
        double cog = gnss.getCog();
      
        Serial.println("");
        Serial.print(date.year);
        Serial.print("/");
        Serial.print(date.month);
        Serial.print("/");
        Serial.print(date.date);
        Serial.print(" ");
        Serial.print(utc.hour);
        Serial.print(":");
        Serial.print(utc.minute);
        Serial.print(":");
        Serial.print(utc.second);
        Serial.println();
        Serial.println((char)lat.latDirection);
        Serial.println((char)lon.lonDirection);
      
        Serial.print("lat degree = ");
        Serial.println(lat.latitudeDegree, 6);
        Serial.print("lon degree = ");
        Serial.println(lon.lonitudeDegree, 6);
      
        Serial.print("satellites used = ");
        Serial.println(starUsed);
        Serial.print("altitude = ");
        Serial.println(high);
        Serial.print("speed over ground = ");
        Serial.println(sog);
        Serial.print("course over ground = ");
        Serial.println(cog);
        Serial.print("GNSS mode = ");
        Serial.println(gnss.getGnssMode());
      
        delay(1000);
      }
      
      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post