0

I'm working on a drone project using a mobile phone do send pitch/roll/throttle and yaw to a Rpi 4 2GB over bluetooth. This is no problem. But, then I want to send these values to the flightcontroller using the serial port (UART) (sending a bytearray at baudrate 115200). When run the program I get no errors from the PI, but the flightcontroller won't get any values. Is it at all possible to use BT and UART at the same time on RPi?

  • Hi @Svein-Tore Narvestad, Ah, let me see. Let me first summarize your config: (1) Android phone sends pitch/roll/throttle/yaw data to Rpi4B, OK, (2) Now you want Rpi4B to send byteArray data to flight controller, say PixHawk 4, by UART at 115,200 baud. (3) I think it is OK for Rpi4B to talk both BlueTooth and Serial UART at the same time. Of course you can verify my guess by doing the following: (a) Disable Bluetooth connect/pairing, (b) Test Rpi4B to PixHawk4 UART talking. Ah, dinner time. See you late this evening or tomorrow. Cheers. – tlfong01 Nov 04 '19 at 09:08
  • 1
    The information about which modules to use for the serial communication to work properly are missleading, to say the least. I was experimenting a day to get the UART to work, but now the BT is off - still haven't investigated further on this. However, the Pi4 has 4 Uarts, so you might not need to worry about the hasles of the primary one. – PMF Nov 04 '19 at 09:32
  • @PMF, Yes I remember in those old Rpi2 days, you could not use BlueTooth and UART together, and GPIO might affect 3.5 mm audio quality. I thought there is no such restriction on RM3B+ and after. I usually test Rpi on board UART and USB to serial adapter at the same time. And Rpi3B+/Rpi4B BlueTooth is still buggy, so I am not longer seriously using BT and UART at the same time. – tlfong01 Nov 04 '19 at 12:32
  • @PMF how to use the other uarts, I only know about /dev/ttyS0 and I use that. – Svein-Tore Narvestad Nov 04 '19 at 17:46
  • @tlfong01 I'm using flightcontroller KK215. I haven't tried to disabled BT yet, but that my next try. I don't fintd the BT buggy though, that part works perfect. But my android phone is sending every 70msecs, that might be too though? – Svein-Tore Narvestad Nov 04 '19 at 17:51
  • @Svein-ToreNarvestad I haven't tried it out yet, but I guess it should work using dtoverlay=uart2, see /boot/overlays/README. – PMF Nov 04 '19 at 19:39
  • Have now tested a bit. Added dtoverlay=uart3 in config.txt. Result: I lost the BT connection (not able to run sdptool. To use bluetooth I must run the command sudo Sdptool add --channel=22 SP The pi will respond with Serial Port service registered but not when I use uart3. Tried to use uart5. Then BT works OK, but I'm not able to use the serial port. For uart5 TXD is on GPIO12. Maybe there is a kind of conflict there, that GPIO12 is used to something else? I get no error messages though. I will try to test uart2 and uart4 tomorrow. – Svein-Tore Narvestad Nov 07 '19 at 20:13
  • Finally it worked. I'l – Svein-Tore Narvestad Nov 08 '19 at 21:06

1 Answers1

0

This Answer is misleading, and does not answer the Question. It is possible to use Bluetooth AND serial - use /dev/serial0 If you need to use UART0 it is still possible to use Bluetooth.

According to RPi 4 overlays readme you have to turn off Bluetooth to use UART0. You should test alternative UART pins.

Name: disable-bt

Info: Disable onboard Bluetooth on Pi 3B, 3B+, 3A+, 4B and Zero W, restoring UART0/ttyAMA0 over GPIOs 14 & 15.

N.B. To disable the systemd service that initialises the modem so it doesn't use the UART, use 'sudo systemctl disable hciuart'.

Load: dtoverlay=disable-bt

Lukasz
  • 16
  • OK, summarizing, I can't use BT and uart0 at the same time. Using Uart1 is OK, activating by:Info: Change the pin usage of uart1 Load: dtoverlay=uart1,= Params: txd1_pin GPIO pin for TXD1 (14, 32 or 40 - default 14)
        rxd1_pin                GPIO pin for RXD1 (15, 33 or 41 - default 15)
    
    – Svein-Tore Narvestad Nov 06 '19 at 21:08
  • Finally it works. I'm using uart5 and fixed it with dtoverlay. Unfortunately there was an error in my code. I forgot to change from ttyS0 to ttyAMA1 – Svein-Tore Narvestad Nov 08 '19 at 21:10