Reversed question marks reading GPS module

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
MineAle
Posts: 4
Joined: Thu Dec 03, 2020 5:15 pm

Reversed question marks reading GPS module

Post by MineAle »

Hi everyone!
I'm trying to read GPS data with STM32 board but I've some issues. I'using FTDI serial to program my board and I connected GPS TX to PA3 (RX2) and GPS RX to PA2 (TX2). When I open the serial monitor I can see only reversed question marks. This is the code I'm using:

Code: Select all

void setup() {
  Serial1.begin(57600);
  //gps_setup();
}

void loop() {
  
  Serial1.begin(57600);
  gps_setup();
  delay(200);

}

void gps_setup(void) {

  Serial1.begin(9600);
  delay(250);

  //Disable GPGSV messages by using the ublox protocol.
  uint8_t Disable_GPGSV[11] = {0xB5, 0x62, 0x06, 0x01, 0x03, 0x00, 0xF0, 0x03, 0x00, 0xFD, 0x15};
  Serial1.write(Disable_GPGSV, 11);
  delay(200);   //A small delay is added to give the GPS some time to respond @ 9600bps.
  //Set the refresh rate to 5Hz by using the ublox protocol.
  uint8_t Set_to_5Hz[14] = {0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xC8, 0x00, 0x01, 0x00, 0x01, 0x00, 0xDE, 0x6A};
  Serial1.write(Set_to_5Hz, 14);
  delay(200);   //A small delay is added to give the GPS some time to respond @ 9600bps.
  //Set the baud rate to 57.6kbps by using the ublox protocol.
  uint8_t Set_to_57kbps[28] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00,
                               0x00, 0xE1, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE2, 0xE1
                              };
  Serial1.write(Set_to_57kbps, 28);
  delay(200);

  Serial1.begin(57600);
  delay(200);
}
What I've done:
  1. I tried changing Serial1 with Serial2 but in this case nothing appears on serial monitor. Actually Serial1 should be the right serial for TX2 and RX2 as I read.
  2. I've tested GPS module with U-center and it works.
  3. I changed also boud rate to 9600 for GPS module from U-center but it still not work.
  4. Read every kind of discussion about this argument...
Someone ever had problem like this with PA2 and PA3?
Is it possible TX2 and RX2 have to be enable before using them? And do you know how from FTDI serial adapter?

Thank you all!
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: Reversed question marks reading GPS module

Post by mlundin »

Please use the appropriate forum section for your question or comment. This section is for forum rules and similar administrative stuff.

Second in order to answer your question we must know what board you are using. But from the results you get it seems that the Serial1 object is connected to the FTDI, since there is output to the serial monitor, and not to the GPS. What you see on the monitor is the data you tried to send to the GPS. Make sure Serial1 and serial monitor has the same baud rate settings.

So you need a Serial2 object also to talk to the GPS, declare it outside the setup and loop functions.

Code: Select all

//                                  RX    TX
HardwareSerial Serial2(PA3, PA2);
The Serial2 object must be configured in setup() in a similar fashion to Serial1.

This only works if that pin combination is defined as serial pins for your board variant, and we dont know that since we dont know what board you use.
MineAle
Posts: 4
Joined: Thu Dec 03, 2020 5:15 pm

Re: Reversed question marks reading GPS module

Post by MineAle »

Sorry, my fault. I'll pay more attention next time. Tell me if it's necessary to repost on the correct section.
I'm using STM32F103C. I tried with the code you linked but it doesn't compile and gives me this error:
no matching function for call to 'HardwareSerial::HardwareSerial(<anonymous enum>, <anonymous enum>)'
I suppose this solution doesn't not work for my board, am I right?
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: Reversed question marks reading GPS module

Post by mlundin »

What model/maker of board and what board settings in the Arduino IDE, there are many boards with STM32F103C, thats just the processor variant ?
MineAle
Posts: 4
Joined: Thu Dec 03, 2020 5:15 pm

Re: Reversed question marks reading GPS module

Post by MineAle »

I attached an images with settings in Arduino IDE. Thanks for your help.
Attachments
Schermata 2020-12-03 alle 21.07.48.png
Schermata 2020-12-03 alle 21.07.48.png (14.76 KiB) Viewed 3965 times
LORDHADES
Posts: 24
Joined: Thu Nov 19, 2020 4:53 am

Re: Reversed question marks reading GPS module

Post by LORDHADES »

Hey there,

I'm not an expert, but with my previous experience with serial communication on STM32, I guess I can give a clarification.
You have received reversed question mark(I too received those buddies...), which means, no data is received.

The problem is(I guess), you are using Serial1 to both receive and show received data on serial monitor. Plus, you are using Serial1.begin() frequently. Just use it in main or loop, that's enough. There may be a conflict because of this case.
You may modify and try the below code:

Code: Select all

int gpsData; //to save data from Serial1

void setup() 
{
  Serial.begin(57600); //to show received data on serial monitor
  Serial1.begin(57600); //to receive data from gps, you can use Serial2.begin() too
  //use same baud rate
  //gps_setup();
}

void loop() 
{
  gps_setup();
  delay(200);
}

void gps_setup(void) 
{
...... //your code here
gpsData = Serial1.read(); ...... //use Serial1 to just receive/send data from/to GPS
Serial.write(gpsData); ......//use Serial.print(gpsData); or Serial.println(gpsdata); according to your need
...... //don't create conflict by using Serial.begin() frequently
}
Try it.. It may work. :-)

HADES
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Reversed question marks reading GPS module

Post by stevestrong »

Rx2 and Tx2 pins are connected to Serial2, so this is what you have to use in your sketch.
If you do not receive anything on Serial2, try to exchange the pins.
You do not need to do Serialx.begin() in loop, do it only one time in setup().
Post Reply

Return to “General discussion”