Trouble using Serialport with GPS Modul. Nano 33 IoT

Hello Maker,
I am having problems communicating with a GPS module via Serial1 with a Nano 33 IoT connected to TX,RX,GND & 3.3V.
The Nano 33 IoT is connected to the Arduino Cloud via WiFi.
When the GPS module is connected, the Nano 33 IoT seems to reboot or hang.

Everything works fine when I use the module with my Nano 33 BLE.

Does anyone have any ideas? Is my Arduino broken?

Perhaps provide some more details ?

For instance are you sugegsting that if you load and run a simple LED blink type sketch, when you then just connect the GPS (with the simple blink sketch running) the Arduino hangs or re-boots ?

Hi @srnet and thanks for the quick reaction on my question.
Yes I have some lines of code to switch the builtin LED on and off. Everything works fine and I can control the LED via Arduino IoT Cloud. As long as there is no GPS connect to the serial Port.

As a next step I connected the GPS only to (3,3V) & (GND) on the Nano 33 IoT, in order to see if there is enough power to drive the GPS module. Yes it is, still working.

Finally I connected (TX) and (RX). But now, when I power up this setup, the behavior in serial monitor seems, that board is restarting and disconnecting and connecting and so on.

Strange behavior: When I cutoff the power (3,3V) between the GPS and the board, some lines of GPS sentences find their way to the monitor before the monitor shows serial port unavailable.

The setup is powered via USB.
The GPS module works fine, when I connect it to another Project, which is built around a Nano 33 BLE.

Here is the Code of the simple Setup:

/* 
  
*/

#include "thingProperties.h"


void setup() {
  // Initialize serials :
  Serial.begin(9600);
  delay(1000); 
  
  Serial1.begin(9600);
  delay(1000);
  
  // Defined in thingProperties.h
  initProperties();
  
  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
  pinMode(LED_BUILTIN, OUTPUT);
  
  led=false;
  myLocation = Location(55.5,8.88); 
}

void loop() {
  ArduinoCloud.update();
  
  if (Serial1.available()){
    String msgtxt=Serial1.readString();
    gpssentence=msgtxt;
    Serial.print(msgtxt);
  }
}

/*
 onLedChange() is executed every time a new value is received from IoT Cloud.
*/
void onLedChange()  {
  Serial.print("Led status changed:");
  Serial.println(led);
  digitalWrite(LED_BUILTIN, led);  
}

I found the solution to my Problem. :slight_smile:
The Serial1.readString() was responsible for the behavior. The functions doesn't found an end and doesn't stop reading from Serial1.

My other gps Project (Nano 33 BLE) is reading and analyzing the gps sentence byte by byte, so everything works fine.

For a quick check, I changed the line to Serial1.readStringUntil(char(10)) , because the sentences are terminating with CR and LF.

Another solution is, setting a Timeout, how long readString is waiting until it terminates. Serial1.setTimeout(* milliseconds*) . The default 1000 (1 second) is too long for a gps that send a new sentence in a frequent of 1Hz.

Hope I described it well.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.