2

I am using the hardware serial ports of Atmega 328 to connect to a GPS module . A GSM SIM900 module is connected via Software serial . Is it possible to print the debug statements in the Serial window while the GPS module is connected to the hardware serial ports? Both my module and the Serial window is set to 9600 bps baud rate . Also I want to read the GSM responses from the Software serial and print the same in the Serial window for debugging. Is this possible?

3
  • I am using the following statements for the latter function:
    – Vj1989
    Jun 2 '17 at 17:25
  • I am using the following statements for printing the GSM responses : Serial.print (softserial.read()) . Is this possible while I am connecting GPS module to the hardware serial ports?
    – Vj1989
    Jun 2 '17 at 17:31
  • You can edit your question. No need to add additional info into the comments.
    – gre_gor
    Jun 2 '17 at 17:40
3

Is it possible to print the debug statements in the Serial window while the GPS module is connected to the hardware serial ports?

Yes, that works. If you connect the Arduino TX pin 1 to the GPS RX, then everything you print to Serial goes to both the Serial Monitor window and the GPS device.

This works, because:

  • It's ok if you see the GPS configuration commands (if any) on the Serial Monitor window. Your debug prints will appear after them.
  • The GPS device ignores anything that doesn't start with a '$' character; it ignores all your debug prints.
4
  • Just make sure the debug information never includes a $ at the start!
    – Gerben
    Jun 2 '17 at 18:54
  • 1
    If you don't ever need to send anything to the GPS module then you don't need to connect the Arduino's TX pin to it.
    – Majenko
    Jun 2 '17 at 19:52
  • @ Gerben .. Thanks.. @ Majenko .. will it do any harm if the pins are connected? My code is using only the commands to read from the gps. What are the possible data / commands that can be sent to the gps other than these?
    – Vj1989
    Jun 3 '17 at 4:39
  • @Vj1989, no harm to the pins (there are resistors on board to allow this). As for other data and messages from the GPS, my NeoGPS library has a nice table here. It's the smallest, fastest, most reliable and most accurate GPS library out there. Commands that you can send to the GPS would be documented in the spec for your device.
    – slash-dev
    Jun 3 '17 at 15:01
0

While I agree with slash-dev, I feel unless you're really struggling with pin real state, you don't really need to have both the GPS serial and UART on the same pins (unless I'm missing some point or convention, in which case please do correct me).

When I was using a GPS module (GTOP013) with an Atmega328p, I just used the SoftwareSerial library to configure some unused pins (12 and 13 I think? it's been a while) as a dedicated RX/TX lines to the GPS, whilst the atmega's RX/TX remained reserved for a USB connection. Any time I needed anything sent to or from the GPS, I had a function to handle that. Also allowed me to keep polling the lines for data from the GPS to be printed onto the Serial.Console as desired for debugging.

2
  • @ Zaeche .. I'm using software serial pins for a GSM device and the program is not working when GPS is also connected to another set of Software serial pins. That's the reason why I'm using hardware serial ports for GPS.
    – Vj1989
    Jun 3 '17 at 4:32
  • Ah, I understand--thanks for clearing that up. I assume you'd prefer to Rx/Tx from the GSM and GPS simultaneously, as well as being able to debug using the hardware serial (thus, 1 hardware serial port + 2 software serial port). As per this, serial ports can't be heard in tandem so I see why you had to reuse the hardware port for the GPS as well (the Mega has two hardware ports but honestly isn't as portable as the 328p).
    – Zaeche
    Jun 3 '17 at 4:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.