I tried to connect Adafruit Ultimate Breakout GPS module using RX and TX to upload data to Arduino IoT Cloud, However the MKR KEEPS DICONNECTING!! after declaring a new port using the Adafruit_GPS library (Adafruit_GPS GPS(&mySerial) but it worrks fine when I comment the previous line "Adafruit_GPS library (Adafruit_GPS GPS(&mySerial)
", I tried to create a new serial port using this link https://docs.arduino.cc/tutorials/communication/SamdSercom/ but it didnot work! following is my full code:
#include "thingProperties.h"
#include <Wire.h>
#include <Adafruit_GPS.h>
#include <Arduino.h>
#include "wiring_private.h"
Uart mySerial (&sercom3, 1, 0, SERCOM_RX_PAD_1, UART_TX_PAD_0); // Create the new UART instance assigning it to pin 1 and 0
void SERCOM3_Handler()
{
mySerial.IrqHandler();
}
// Use Serial1 for the GPS module
Adafruit_GPS GPS(&mySerial);
#define GPSECHO false
//#define GPSECHO false
//uint32_t timer = millis();
void setup() {
mySerial.begin(9600);
pinPeripheral(1, PIO_SERCOM); //Assign RX function to pin 1
pinPeripheral(0, PIO_SERCOM); //Assign TX function to pin 0
Serial.begin(115200);
//Serial2.begin(9600);
// 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
// GPS.begin(9600);
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
//GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
// GPS.sendCommand(PGCMD_ANTENNA);
// GPS.sendCommand(PMTK_SET_BAUD_115200);
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
delay(1000);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
}
Appreciate your help