0

I am using Rpi 3b+ and I am trying to use the Bluetooth and UART simultaneously.

with ls -l /dev:

Serial 0- ttyAMA0
Serial 1 - ttyS0

I had to use the UART(for reading coordinates in gps) and meanwhile connect bluetooth and output the audio from the audio jack.

things I did:

sudo systemctl stop [email protected]
sudo systemctl disable [email protected]
sudo systemctl stop [email protected]
sudo systemctl disable [email protected]

in config.txt:

enable_uart = 1
dtoverlay=miniuart-bt
core_frequency=250

in cmdline.txt:

dwc_otg.lpm_enable=0 console=tty1 

my gps code :

import serial
import time
import string
import pynmea2

while True:
    port="/dev/ttyAMA0"
    ser=serial.Serial(port, baudrate=9600, timeout=0.5)
    dataout = pynmea2.NMEAStreamReader()
    newdata=ser.readline()

    if newdata[0:6] == "$GPRMC":
        newmsg=pynmea2.parse(newdata)
        lat=newmsg.latitude
        lng=newmsg.longitude
        gps = "Latitude=" + str(lat) + "and Longitude=" + str(lng)
        print(gps)

The gps data is coming, the bluetooth getting connected to phone but the audio is not okay. it is playing sometimes and then breaking.

Can I in any way swap the functionalities. ttyAMA0 would be for bluetooth and ttyA0 would be for gps communication.

AFTER REVERTING:

I got a new sd card, enabled only the serial intarface.

ls -l /dev:

Serial 0- ttyS0 Serial 1 - ttyAMA0

Uart and Bluetooth works fine.

Reverting changes in old sd card:

I removed the dtoverlay=miniuart-bt and enable_uart = 1 again turned on serial through sudo raspi-config

But ls -l /dev gives me only Serial 1 - ttyAMA0.

I am not able to find the /dev/serial0

2
  • You don't do yourself any favours by posting rubbish. ls -l /dev/serial* shows lrwxrwxrwx 1 root root 5 Apr 30 09:17 /dev/serial0 -> ttyS0 lrwxrwxrwx 1 root root 7 Apr 30 09:17 /dev/serial1 -> ttyAMA0 - nothing like your post. You appear to have disabled services which you also have to revert. I suggest you just use the new SD Card.
    – Milliways
    May 15 at 11:15
  • lrwxrwxrwx 1 root root 7 May 15 15:47 /dev/serial1 -> ttyAMA0 this is what i meant while running ls -l /dev/
    – Aryan
    May 15 at 11:30

1 Answer 1

0

If you didn't fiddle with things and enabled serial in raspi-config it should work using /dev/serial0 which will ALWAYS be the available serial port on GPIO 14/15.

What you claim to want is how it works if you don't break it.

4
  • I did the same but the gps data is not coming.
    – Aryan
    May 14 at 12:38
  • can in any way i can revert those changes. now it is not showing serial0. only serial 1 is showing
    – Aryan
    May 15 at 9:37
  • You claim to have "reverted" changes but provided no details. As it currently stands your question is unchanged so no one knows what you have. If it was me I would just restore from my backup.
    – Milliways
    May 15 at 9:49
  • I tested in a new sd card. just by enabling the serial and both uart and bluetooth are working fine. Now after reverting the changes in the old sd card it doesnot at all shows /dev/serial0. I have edited my question. please check
    – Aryan
    May 15 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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