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);
}