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, so 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
:
UART and Bluetooth works fine.Serial 0 - ttyS0 Serial 1 - ttyAMA0
Reverting changes in old SD card:
- I removed the
dtoverlay=miniuart-bt
andenable_uart = 1
again turned on serial throughsudo raspi-config
- But
ls -l /dev
gives me only
I am not able to find theSerial 1 - ttyAMA0
/dev/serial0
ls -l /dev/serial*
showslrwxrwxrwx 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.