1

I am using Raspberry Pi 4 (OS:bullseye, version 11) and Neo 6 GPS. I have tried to follow the tutorial https://www.instructables.com/Interfacing-GPS-Module-With-Raspberry-Pi/ but I am stuck at step 8. The command sudo cat /dev/ttyAMA0 hangs no matter what I do. I strongly suspect that it has something to do with Raspberry Pi 4. Few things I noticed/followed -

  1. The blue light on the antenna is blinking.
  2. Followed other similar threads such as How can Rpi connect a GPS module? but it did not help. Has anybody figured out how to make Neo 6 GPS work with Raspberry Pi4?

[Moved content from comments to the main body of the question]

  1. Connected Vcc of GPS module to Power Supply (5V) of Raspberry Pi Connected Tx (Transmitter Pin) of GPS module to Pin No.10 of Raspberry Pi. Connected GND (Ground Pin) of GPS module to GND of Raspberry Pi

  2. Modified /boot/config.txt as following. Added the code at the end dtparam=spi=on dtoverlay=disable-bt (#note for Pi 4, only 'disable-bt' works, 'pi3-disable-bt' gives warning at the bootup time) core_freq=250 enable_uart=1 force_turbo=1

  3. Edited /boot/cmdline.txt and replaced its content with the following dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles

  4. Disable the Raspberry Pi Serial Getty Service

    1. If in your output, Serial0 is linked with ttyAMA0, then to disable it use the below command, sudo systemctl stop serial-getty@ttyAMA0.service sudo systemctl disable serial-getty@ttyAMA0.service
    2. If in your output Serial0 is linked with ttys0, then to disable it use the below command, sudo systemctl stop serial-getty@ttys0.service sudo systemctl disable serial-getty@ttys0.service I followed (1) here.
  5. Activate ttys0 To enable the ttys0 use following command, sudo systemctl enable serial-getty@ttys0.service1

  6. sudo apt-get install minicom sudo pip install pynmea2

Now, when I issue the command - sudo cat /dev/ttyAMA0, the command just hangs. I see the blue light blinking on the antenna. Also, note that I had used old version of Raspberry pi (2011-12) and it gave correct output when I typed sudo cat /dev/ttyAMA0. The reason I am using raspberry pi 4 is I want it to be powered by batteries and the case of the batteries is compatible with pi 4. That way, I can use it in outdoor settings. Second, version 2011-12 is so old that I thought it is better to move on to latest robust version.

Raspberry Pi 4 has OS bullseye. I am aware that with newer versions, there is a GUI to configure the settings instead of manipulating config or boot files but I don't think it should matter. I do not know what I am missing or how to diagnose the problem. Is there a difference between Pi4 and earlier versions as far as ttyAMA0 goes?

Rohit Gupta
  • 343
  • 2
  • 4
  • 11
SSN
  • 11
  • 2

1 Answers1

0

NEW:

Yesterday late, I have a thought; "What is core_freq=250?". I searched on raspberry pi what is the frequency of core_freq=250 enable_uart=1 force_turbo=1. And found https://forums.raspberrypi.com/viewtopic.php?t=213499 which states "The Linux console can be re-enabled by adding enable_uart=1 to config.txt. This also fixes the core_freq to 250Mhz (unless force_turbo is set, when it will fixed to 400Mhz), which means that the UART baud rate stays consistent", by PhilE Raspberry Pi Engineer & Forum Moderator. So, my OLD answer of 2.5Mhz will not help you as your device is rumming at 400Mhz and the RPI 4B uarts can NOT be set at 400Mhz (stty -F /dev/ttyAMA1 400000000), only the mini UART (UART1) can do that (see https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/configuration/uart.adoc). If you make it work, post your steps and mark it answered.

OLD:

I do not have a Neo 6 GPS, but on the RP 4B there are more UARTs to use instead of 0 and 1. I will provide a short example of how to use UART3 on the RP 4B which you may use to adapt to the GPS device.

#!/usr/bin/env python3

""" EXAMPLE of UART communication on Raspberry Pi 4B using Python.

Multiple UARTs on Raspberry Pi 4B (CM4): TXD RXD CTS RTS Board Pins uart0 14 15 8 10 uart1 14 15 8 10 uart2 0 1 2 3 27 28 (I2C0) uart3 4 5 6 7 7 29 (GPCLK0), (RTS 7 = SPI0-CE1) uart4 8 9 10 11 24 21 (SPI0) uart5 12 13 14 15 32 33 (gpio-fan)

Raspberry Pi 4B (CM4) setup: /boot/config.txt has dtoverlay=uart3, sudo reboot jumper from GPIO pin 4 to GPIO pin 5

https://www.electronicwings.com/raspberry-pi/raspberry-pi-uart-communication-using-python-and-c https://pinout.xyz/pinout/uart https://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-on-the-raspberry-pi3-pizerow-pi4-or-later-models/107780#107780 https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/configuration/uart.adoc https://pyserial.readthedocs.io/en/latest/pyserial_api.html """

import serial from time import sleep

ser = serial.Serial('/dev/ttyAMA1', 2500000, 8, 'N', 1) # Open port print(ser.get_settings) x = 6 while x: ser.write(b'Hello out there!') # Write byarray received_data = ser.read() # Read serial port sleep(0.03) data_left = ser.inWaiting() # Check for remaining byte received_data += ser.read(data_left) print(received_data.decode('utf-8')) # Print received data x -= 1

bstipe
  • 574
  • 4
  • 6