teensy lc gps no data at serial monitor

Status
Not open for further replies.

ChefBigDog

New member
Hello, I am using a teensy lc with a ATGM336H GPS Module. The problem is that when I upload the code and open the serial monitor it does not display any data. I have tried the same "ATGM336H GPS Module" with an arduino Uno (same pins, etc) and it works perfectly. But when I try it with the teensy lc no data is displayed. I have tried many codes and 2 ides (platformio ide and teensyduino) but still no difference.

The code that works with arduino uno but not with teensy;

#include <TinyGPS++.h> // Include the TinyGPS++ library
TinyGPSPlus tinyGPS; // Create a TinyGPSPlus object

#define GPS_BAUD 9600 // GPS module baud rate. GP3906 defaults to 9600.

// If you're using an Arduino Uno, RedBoard, or any board that uses the
// 0/1 UART for programming/Serial monitor-ing, use SoftwareSerial:
#include <SoftwareSerial.h>
#define ARDUINO_GPS_RX 9 // GPS TX, Arduino RX pin
#define ARDUINO_GPS_TX 8 // GPS RX, Arduino TX pin
SoftwareSerial ssGPS(ARDUINO_GPS_TX, ARDUINO_GPS_RX); // Create a SoftwareSerial

// Set gpsPort to either ssGPS if using SoftwareSerial or Serial1 if using an
// Arduino with a dedicated hardware serial port
#define gpsPort ssGPS // Alternatively, use Serial1 on the Leonardo

// Define the serial monitor port. On the Uno, and Leonardo this is 'Serial'
// on other boards this may be 'SerialUSB'
#define SerialMonitor Serial

void setup()
{
SerialMonitor.begin(9600);
gpsPort.begin(GPS_BAUD);
}

void loop()
{
// print position, altitude, speed, time/date, and satellites:
printGPSInfo();

// "Smart delay" looks for GPS data while the Arduino's not doing anything else
smartDelay(1000);
}

void printGPSInfo()
{
// Print latitude, longitude, altitude in feet, course, speed, date, time,
// and the number of visible satellites.
SerialMonitor.print("Lat: "); SerialMonitor.println(tinyGPS.location.lat(), 6);
SerialMonitor.print("Long: "); SerialMonitor.println(tinyGPS.location.lng(), 6);
SerialMonitor.print("Alt: "); SerialMonitor.println(tinyGPS.altitude.feet());
SerialMonitor.print("Course: "); SerialMonitor.println(tinyGPS.course.deg());
SerialMonitor.print("Speed: "); SerialMonitor.println(tinyGPS.speed.mph());
SerialMonitor.print("Date: "); printDate();
SerialMonitor.print("Time: "); printTime();
SerialMonitor.print("Sats: "); SerialMonitor.println(tinyGPS.satellites.value());
SerialMonitor.println();
}

// This custom version of delay() ensures that the tinyGPS object
// is being "fed". From the TinyGPS++ examples.
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
do
{
// If data has come in from the GPS module
while (gpsPort.available())
tinyGPS.encode(gpsPort.read()); // Send it to the encode function
// tinyGPS.encode(char) continues to "load" the tinGPS object with new
// data coming in from the GPS module. As full NMEA strings begin to come in
// the tinyGPS library will be able to start parsing them for pertinent info
} while (millis() - start < ms);
}

// printDate() formats the date into dd/mm/yy.
void printDate()
{
SerialMonitor.print(tinyGPS.date.day());
SerialMonitor.print("/");
SerialMonitor.print(tinyGPS.date.month());
SerialMonitor.print("/");
SerialMonitor.println(tinyGPS.date.year());
}

// printTime() formats the time into "hh:mm:ss", and prints leading 0's
// where they're called for.
void printTime()
{
SerialMonitor.print(tinyGPS.time.hour());
SerialMonitor.print(":");
if (tinyGPS.time.minute() < 10) SerialMonitor.print('0');
SerialMonitor.print(tinyGPS.time.minute());
SerialMonitor.print(":");
if (tinyGPS.time.second() < 10) SerialMonitor.print('0');
SerialMonitor.println(tinyGPS.time.second());
}



I am thinking of changing the Microcontroller to an upgraded Arduino rather than a teensy because of this. I love teensy its better but i have no more solution for this situation. if upgrading the teensy or the gps solves the problem i am wiling to do that but i am not sure
If you can help me thanks. :(
 
Last edited:
First don't despair. I have had many UBLOX modules working with the Teensy (most 3.2 and up) and never had a problem. The first thing I usually do is use a Hardware Serial Port as opposed to using Software Serial. With an Uno you are stuck using Software Serial as Serial1 on the Uno is the same as the USB port.

So I would try using Serial1 on the Teensy LC instead:
Code:
#include <TinyGPS++.h> // Include the TinyGPS++ library
TinyGPSPlus tinyGPS; // Create a TinyGPSPlus object

#define GPS_BAUD 9600 // GPS module baud rate. GP3906 defaults to 9600.

// If you're using an Arduino Uno, RedBoard, or any board that uses the
// 0/1 UART for programming/Serial monitor-ing, use SoftwareSerial:
//#include <SoftwareSerial.h>
//#define ARDUINO_GPS_RX 9 // GPS TX, Arduino RX pin
//#define ARDUINO_GPS_TX 8 // GPS RX, Arduino TX pin
//SoftwareSerial ssGPS(ARDUINO_GPS_TX, ARDUINO_GPS_RX); // Create a SoftwareSerial

// Set gpsPort to either ssGPS if using SoftwareSerial or Serial1 if using an
// Arduino with a dedicated hardware serial port
//#define gpsPort ssGPS // Alternatively, use Serial1 on the Leonardo
#define gpsPort Serial1

// Define the serial monitor port. On the Uno, and Leonardo this is 'Serial'
// on other boards this may be 'SerialUSB'
#define SerialMonitor Serial
This is what it should look like when using a serial Hardware port. You actually have 3 H/W serial ports available. So already one up on the UNO.

One note:
Teensy LC RX is pin 0 which should go to GPS TX.
Teensy LC TX is pin 1 which should go to GPS RX.

Check the pinout card to see the location of pin 0 and pin 1. Or you can check pinouts about this page: https://www.pjrc.com/teensy/teensyLC.html.

The only thing I noticed it may take some time to connect depending on where you have your antenna and if enough satellites are available.
 
first of all thanks for replying to the forum,
I have seen your advice on a forum before and I have tried it but it did not work. But I tried it again and IT WORKED! thanks, I love you. I feel relieved from so much pain. thanks again :)
haha
 
Status
Not open for further replies.
Back
Top