Using bluetooth and dtoverlay=pi3-miniuart-bt

Hi,

I’m having trouble in activating bluetooth in combination with miniuart.
The reason is that /dev/ttyAMA0 is used by my Razberry zwave card.
Thus I need GPIO 14 and 15 available.

~ # cat /mnt/boot/config.txt
kernel=u-boot.bin
disable_splash=1
dtparam=audio=on
dtoverlay=pi3-miniuart-bt
enable_uart=1
core_freq=250

According to https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README

Name:   pi3-miniuart-bt
Info:   Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore
        UART0/ttyAMA0 over GPIOs 14 & 15. Note that this may reduce the maximum
        usable baudrate.
        N.B. It is also necessary to edit /lib/systemd/system/hciuart.service
        and replace ttyAMA0 with ttyS0, unless you have a system with udev rules
        that create /dev/serial0 and /dev/serial1, in which case use
        /dev/serial1 instead because it will always be correct. Furthermore,
        you must also set core_freq=250 in config.txt or the miniuart will not
        work.
Load:   dtoverlay=pi3-miniuart-bt
Params: <None>

I do see dev-ttyAMA0.device hardcoded in this file:

/usr/lib/systemd/system # cat bluetooth-bcm43xx.service
[Unit]
Description=Bluetooth for BCM43xx
Before=bluetooth.service
After=dev-ttyAMA0.device
ConditionPathIsDirectory=/proc/device-tree/soc/gpio@7e200000/bt_pins

[Service]
Type=forking
ExecStart=/usr/sbin/bluetooth-bcm43xx

[Install]
WantedBy=hassos-hardware.target

I thought it would need changing to /dev/serial1. But the file is read-only.

But when I try the following on the prompt, I get an error. Thought it should work like this.

~ # hciattach /dev/serial1 bcm43xx 460800 noflow -
bcm43xx_init
Initialization timed out.
~ #

Am not sure what I am missing. Has anyone gotten this to work?

Oh, forgot to add, am using a Raspberry Pi 3B on hassos 1.9 in 32 bit

Identical problem here. Also need the GPIO pins for Razberry

Using bluetooth support results in following error:

2018-08-24 10:03:44 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform bluetooth_tracker
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/bluetooth_tracker.py", line 72, in setup_scanner
    for dev in discover_devices():
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/bluetooth_tracker.py", line 50, in discover_devices
    lookup_class=False)
  File "/usr/local/lib/python3.6/site-packages/bluetooth/bluez.py", line 26, in discover_devices
    device_id = _bt.hci_get_route()
OSError: [Errno 19] No such device

Hardware: RPI3 B+
Software: HassOS 1.9, Supervisor 127, Hass 0.76.2

Hi there,

wanted to use a HomeMatic Shield (as you with zwave) and bluetooth. Think i fixed it. See the trial path below:

Configure for HM/ZWave only
# ssh -l root 192.168.178.87 -p 22222
hassio > login
# vi /mnt/boot/config.txt
SET
dtoverlay=pi3-miniuart-bt
enable_uart=1
# reboot
# systemctl status bluetooth-bcm43xx
-> Bluetooth broken
# ls -la /dev
lrwxrwxrwx 1 root root 7 Nov 9 18:39 serial0 -> ttyAMA0
-> This Points to HM/Zwave Dongle
lrwxrwxrwx 1 root root 5 Nov 9 18:39 serial1 -> ttyS0
-> This Points to Bluetooth. Does not work

Configure for Bluetooh (only)
# ssh -l root 192.168.178.87 -p 22222
hassio > login
# vi /mnt/boot/config.txt
SET
#dtoverlay=pi3-miniuart-bt
#enable_uart=1
# reboot
# systemctl status bluetooth-bcm43xx
-> Bluetooth works
# ls -la /dev
lrwxrwxrwx 1 root root 7 Nov 9 19:21 serial1 -> ttyAMA0
-> This Points to Bluetooth

Configure for both
# ssh -l root 192.168.178.87 -p 22222
hassio > login
# vi /mnt/boot/config.txt
SET
#dtoverlay=pi3-miniuart-bt
enable_uart=1
# reboot
# systemctl status bluetooth-bcm43xx
-> Bluetooth works
# ls -la /dev
lrwxrwxrwx 1 root root 5 Nov 9 19:21 serial0 -> ttyS0
-> This Points to HM/Zwave Dongle
lrwxrwxrwx 1 root root 7 Nov 9 19:21 serial1 -> ttyAMA0
-> This Points to Bluetooth

After changing the config, you have to change the zwave hardware device id from /dev/ttyAMA0 to /dev/ttyS0.
This has to be done, because (as you see above) the binding of the serial devices is swapped between /dev/ttyAMA0 and /dev/ttyS0.

Unfortunately the HomeMatic OCCU integration stays broken - but this should not be a matter of hardware accessibility, but a firmware issue.

Please let me know, if my solution works for you.

Regards,

Jakob

2 Likes

This worked for me!! Thank you very much. ZWave, Homematic and Bluetooth are working at the same time!

1 Like

Which credentials should I use when executing the login command?

I have issues in Hass.io to connect to a Plugwise Zigbee stick and it also seems it is not found by the container I built.

1 Like

If i change my config.txt from:

kernel=u-boot.bin
disable_splash=1
dtparam=audio=on
enable_uart=1
dtoverlay=pi3-miniuart-bt

to

kernel=u-boot.bin
disable_splash=1
dtparam=audio=on
enable_uart=1
#dtoverlay=pi3-miniuart-bt

my pi does not boot anymore. Any ideas? I would like to use my raspbee and bluetooth.

@greetoz: Are you using 64bit HASSOS ? I had same issue with 64bit HASSOS, also boot issues.
But on 32bit HASSOS it will work. Just try it with another SD card and install 32bit version of HASSOS.

Switched to RasPi4 recently. The old options, pointed out above, do no longer work.
Had to disable bluetooth as i found no other way of enabling UART for OCCU:

dtoverlay=uart1
dtoverlay=disable-bt

Someone an idea of enabling UART without breaking Bluetooth?

Setting BT to miniUART should allow foth BT and GPIO at the same time:
/boot/config.txt:

dtoverlay=miniuart-bt
force_turbo=1

The 1st line switches BT to the miniUART and the 2nd line is needed with miniUART BT to set the VPU core clock to a fixed frequency, this is required based on https://www.raspberrypi.org/documentation/configuration/uart.md / UARTs and Device Tree -section, 3rd chapter.

This works now ok in my setup, BT can find RuuviTags and Z-Wave scanning with the RazBerry2 hat works

1 Like

I’ve switched force_turbo=1 with core_freq=250 as there were some BT related errors visible in system log. After the switch I have not yet seen any BT errors.
With those configurations I have Home Assistant with RazBerry2 Z-Wave hat and BlueTooth working simultaneously.

3 Likes

Hey, I’ve tried all what you mentioned for my config on rpi4b. I’ve purchased RaspbeeII module and somehow I’ve managed to make it work. Configured also Zigbee Home assistant and detected my ikea switches. But all my Xiaomi BLE thermo&humidity sensor stopped working as they were configured with BT (flashed firm).

The only place I’ve found for something related is this one: Integrate RaspBee 2 into Home Assistant - Robin Bühler

And this is my current config:

#Config for RaspbeeII
enable_uart=1
dtparam=i2c_arm=on
dtparam=i2c_vc=on
dtoverlay=miniuart-bt
dtoverlay=i2c-rtc,pcf85063

I have a Rpi 3b+ and RaspBee I and having the onboard Bluetooth enabled always caused many problems so I turned it off and even the wifi:
dtoverlay=disable-bt
dtoverlay=disable-wifi (I use ethernet cable)
I added an external BT dongle on an extender cable, an old one that is less annoying 4.2 than the latest 5.0 +, and in this way, I can have BT and BLE presence (etc.) and Raspbee work more stable.

I’ve done the same ultimately. Bought an usb dongle for BT and disable BT and wifi internally since I also have it connected via cable and looks like I got some progress but my switches are not working with my hue lights:

The raspbeeII is always offline but on 1 switch and the other device I got connection. The other is inexistent no matter what I do.

Thanks, Sam.