Teensy 4.1 + GPS uBlox Neo 6M - no data received

SonicPKMN

Member
Hello,

I'm trying to receive data using a Teensy 4.1 and a GPS module but with no success. At first I just want print the NMEA data at the terminal but I receive nothing.

This is code I'm using. The RX/TX pins of the GPS module are connected to the pins 7/8 of the Teensy (The TX of the GPS module to the RX of the Teensy and the RX of the GPS module to the TX of the Teensy).

The Serial Monitor at the Arduino IDE remains empty. Do you have any ideas? Probably I am missing something here. Just a note that the GPS module is functioning properly with a RaspeberryPi that was connected via its UART.

Thanks!


My code:

Code:
void setup(){
  Serial.begin(9600);
  Serial2.begin(9600);
}

void loop(){
  while (Serial2.available() > 0){
    char gpsData = Serial2.read();
    Serial.write(gpsData);
  }
}


My setup:

IMG_20230819_214323.jpg
IMG_20230819_214404.jpg
 
Also would recommend printing *something* to the serial monitor when no data arrives, so you can tell the difference between no data and a problem like wrong port selected (to something else which doesn't send anything).

Code:
void setup(){
  Serial.begin(9600);
  Serial2.begin(9600);
}

void loop(){
  while (Serial2.available() > 0){
    char gpsData = Serial2.read();
    Serial.write(gpsData);
  }
  static elapsedMillis timeout;
  if (timeout > 2000) {
    timeout = 0;
    Serial.print("Hello World ");
    static unsigned int count = 0;
    Serial.println(count++);
  }
}
 
Thanks for the answer. I tried 4800 baud rate but nothing received. Just to mention, I have tried other serial ports as well.

EDIT: I have also changed the wires connecting the Teensy with the GPS module, just in case.
 
Last edited:
your photos suggest you are using 5v from Teensy to power ublox. Teensy 4.1 is NOT 5v tolerant. you may have damaged the Rx pin on the Teensy. You should power ublox from 3v3 pin

I have NEO-M8U and NEO-M9N, and both work fine with Teensy 4.1. GPS's are powered from Teensy 3.3v
 
Last edited:
Did you run the program in msg #3?

Seeing a blank serial monitor window could mean something is wrong between Teensy and Arduino IDE (selecting wrong port is most common problem). Seeing it print the Hello World messages but not seeing data can at least rule out that possibility.
 
Did you run the program in msg #3?

Seeing a blank serial monitor window could mean something is wrong between Teensy and Arduino IDE (selecting wrong port is most common problem). Seeing it print the Hello World messages but not seeing data can at least rule out that possibility.

Yep, I run that and it just continuously prints "Hello World " and the increasing number. Nothing more.

Screenshot 2023-08-20 115908.png
 
Last edited:
your photos suggest you are using 5v from Teensy to power ublox. Teensy 4.1 is NOT 5v tolerant. you may have damaged the Rx pin on the Teensy. You should power ublox from 3v3 pin

I have NEO-M8U and NEO-M9N, and both work fine with Teensy 4.1. GPS's are powered from Teensy 3.3v

Yes, I used 5V but at some point I used the 3.3V pin as well but with the same end result. I will switch back to 3.3V and use another serial port, just in case.

I also tried this example https://icircuit.net/arduino-esp32-hardware-serial2-example/3181 (I modified the code a bit), just to check what you said, to see if the RX/TX pins work. Basically echo what is sent to the pin. And it worked as the example says (using the Serial2 output). I will recreate it and post back.

Code:
void setup() {
  Serial.begin(9600);
  Serial5.begin(9600);
  delay(1000);
  Serial.println("Loopback program started");
}
void loop() {
  if(Serial.available()){
    Serial.write("-");
    Serial5.write(Serial.read());  
  }
  if(Serial5.available()){
    Serial.write(".");
    Serial.write(Serial5.read());  
  }
}

Screenshot 2023-08-20 120245.png

IMG_20230820_121506.jpg
 
Last edited:
your photos suggest you are using 5v from Teensy to power ublox. Teensy 4.1 is NOT 5v tolerant. you may have damaged the Rx pin on the Teensy. You should power ublox from 3v3 pin

I have NEO-M8U and NEO-M9N, and both work fine with Teensy 4.1. GPS's are powered from Teensy 3.3v

Tested again with Serial5 and 3.3V. Same results. (also changed the USB cable connecting Teensy to the PC, just in case)


Code:
void setup(){
  Serial.begin(9600);
  Serial5.begin(9600);
}

void loop(){
  while (Serial5.available() > 0){
    char gpsData = Serial5.read();
    Serial.write(gpsData);
  }
  static elapsedMillis timeout;
  if (timeout > 2000) {
    timeout = 0;
    Serial.print("Hello World ");
    static unsigned int count = 0;
    Serial.println(count++);
  }
}

View attachment 31805

IMG_20230820_120840.jpg
 
do you have a scope or analyzer that you can attach to GPS TX pin? Is there a GPS LED that blinks to confirm that GPS has sync'd with the satellites?
 
do you have a scope or analyzer that you can attach to GPS TX pin? Is there a GPS LED that blinks to confirm that GPS has sync'd with the satellites?

Unfortunately not. Can I use a multimeter somehow just to measure voltage? (I'm quite new to this stuff).

Yes there is a LED on the GPS which at first is solid which means it is does not have a fix yet and later it starts blinking which means it got a fix. This works as expected.
 
Here is a simple sketch to count rising pulses on pin 0. Connect GPS TX to Teensy pin 0.
Code:
volatile uint32_t ticks;
void ding() {
  ticks++;
}

void setup() {
  Serial.begin(9600);
  while (!Serial);
  attachInterrupt(0, ding, RISING);
}

void loop() {
  static uint32_t prev = 0;
  delay(1000);
  Serial.println(ticks - prev);
  prev = ticks;
}
With my GPS i see about 2300 ticks/sec
Code:
2359
2303
2336
2309
2352
2328
...
 
Know I am jumping in here late but it looks like you have Rx on the GPS going to Rx (serial 5). Try swapping it so so Rx on the GPS goes to the Tx on the Teensy (pin 20). In other words RX->TX and Tx->Rx
 
Know I am jumping in here late but it looks like you have Rx on the GPS going to Rx (serial 5). Try swapping it so so Rx on the GPS goes to the Tx on the Teensy (pin 20). In other words RX->TX and Tx->Rx

I check that and they are connected correctly as you said.
 
Here is a simple sketch to count rising pulses on pin 0. Connect GPS TX to Teensy pin 0.
Code:
volatile uint32_t ticks;
void ding() {
  ticks++;
}

void setup() {
  Serial.begin(9600);
  while (!Serial);
  attachInterrupt(0, ding, RISING);
}

void loop() {
  static uint32_t prev = 0;
  delay(1000);
  Serial.println(ticks - prev);
  prev = ticks;
}
With my GPS i see about 2300 ticks/sec
Code:
2359
2303
2336
2309
2352
2328
...


I uploaded the code and I got the following. Probably this is bad?

Screenshot 2023-08-21 082552.png

IMG_20230821_082853.jpg

IMG_20230821_082825.jpg
 
Weird. Test it with a few non-UART pins, e.g. change the first argument of attachInterrupt(pin, ....) and attach GPX TX pin

do you have another Teensy that you can try?
 
Last edited:
Weird. Test it with a few non-UART pins, e.g. change the first argument of attachInterrupt(pin, ....) and attach GPX TX pin

I replaced the TX cable and I saw data! I had a bunch of cables and most of them do not make contact. I found a few that may work. As a result, fortunately it was a wiring issue.

Thanks all for the help!

Screenshot 2023-08-21 135641.png
 
Back
Top