Hello guys I wanted to try the NEO-6M GPS Module but I only see special characters in the Serial Monitor like this: "��������������”
this is the example code Im using:
#include <HardwareSerial.h>
HardwareSerial SerialGPS(1);
void setup() {
Serial.begin(115200); // Monitor Serial (PC)
SerialGPS.begin(9600, SERIAL_8N1, 16, 17); // GPS en pines 16 (RX) y 17 (TX)
Serial.println("Iniciando prueba GPS...");
}
void loop() {
while (SerialGPS.available() > 0) {
char c = SerialGPS.read();
Serial.print(c); // Reenvía TODO lo que mande el GPS al monitor
}
}
In the serial Monitor I have 11520 and I can see the message "Iniciando prueba GPS..."
The problem is the data that the GPS is giving me.
Im using a ESP32 and the connections are the following:
I moved your topic to an appropriate forum category. Don't write in English in the Spanish speaking category.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
Hello, do yourself a favour and please read How to get the best out of this forum and post accordingly (including code with code tags and necessary documentation for your ask like your exact circuit and power supply, links to components etc).
Please correct your post and add code tags around your code.
There is a small pencil below your existing posts.
click on this pencil ➜ that will let you edit your post.
Select the part of the text that corresponds to the code
Click on the <code/> icon in the toolbar to indicate that it is code
click Save Edit
(Also make sure to properly indent the code in the IDE before copying and pasting it here. This can be done by pressing ctrlT on a PC or cmdT on a Mac)
Once you have corrected the code tags, can you clarify the power supply ?
can you use this instead of your print code so that we can see exactly the hex message received ?
while (SerialGPS.available()) {
Serial.print(SerialGPS.read(), HEX);
Serial.print(" ");
}
Are you sure the GPS is using 9600? I’ve had one ‘brand new’ Neo module from Amazon that was using 57600 baud and using UBX format rather than the expected NMEA format. I now test new GPS modules using u-center and a FTDI serial to USB adaptor. u-center has an ‘auto baud’ option. There’s no need to connect the ‘send to GPS’ wire, only the ‘receive from GPS wire’ is needed to see the GPS message output.
You should be powering the GPS module with 3.3v not 5v or the logic levels from the GPS module are likely to be exceeding the 3.3v limit on an Esp32
The pins you are using are actually the default pins for UART2 (not UART1) but since you can assign any pin to the UARTs i guess it doesn't matter much.
Your example follows this tutorial i found, so there shouldn't be any other coding issue.
Please check all connections with a DMM (pin on ESP32 to pin on GPS) correct the Vcc connection to 3.3v
The symptom you report suggests a baud-rate mismatch, so if the problem persists, experiment with some baud-rate settings here
Yes it’s okay to do that (my experience of this is with ESP32 Dev Kit C V4 (WROOM-32D)).
I’ve done a couple of successfully working serial projects like that, one receiving from a Neo GPS module and the other talking to a 30 pin iPod serial connection.
I’m not familiar with the HardwareSerial class. My code looks like this:
#define SERIAL_IPOD Serial1
// Define which GPIOs should be used for iPod UART defaults clash with FLASH control
// so use the pins for uart2
#define IPOD_TX_GPIO 17
#define IPOD_RX_GPIO 16
<snip>
int Packet::init()
{
SERIAL_IPOD.begin(_culBaud, SERIAL_8N1, IPOD_RX_GPIO, IPOD_TX_GPIO);
<snip>
In some ways it does make more sense to actually use UART2 in that case. If you happen to call begin() on UART2 after calling it in UART1, the pins will be disconnected from UART1. That said if you call begin() on UART1 with the default pins (on a devkit) usually the ESP32 just crashes.
I can’t remember why I did it like that. I wrote that code about 5 years ago when I didn’t have much ESP32 experience. Now, if I want a harware serial port on one of those devkits I just copy my own code that works without thinking about changing it.
Sorry, this was my first time in the forum, and I barely know about hardware! It will not happen again.
The power supply Im using now is my computer, I have a litium battery but I have not connected yet.
Using the code you pass me this is what appears in my Serial Monitor:
16:06:44.72 -> 000000000000000000000000FF0FF00000000000..
Its the same as the Serial Monitor, but I dont know if it affects something if I put a random baudrate for Serial.begin(...) like 19200, and in the Serial Monitor I put the same (19200).
Don’t! Your Serial.print already works as You said. It shows text properly.
Reading the GPS brings characters. My first approach was wrong, assuming bytes, integers.
It must be a mismatch between the controller and the GPS.
Defining software serial, or serial port, can something be wrong? Are the pin numbers for Rx and Tx correct, not swapped? Is N1 correct? I’ve never set up a hardware serial port….
As @Deva_Rishi already asked, did you try 19200, 38400 & 57600 baudrates?
The symbols displayed on the monitor are typical of a baudrate mismatch (between GPS and ESP, most likely).