Cheap Bluetooth antenna with raspberry pi zero

Hmmm. How are you running sensorReporter?

The error is definitely caused by its inability to import paho. There are two ways to install a python library, globally or for the specific user. You might be installing it as a specific user but sensorReporter is running as a different user and that user doesn’t have paho available.

If you are not going to use sensorReporter (I’d recommend reelyActive instead anyway) don’t worry about an issue. I think the problem is a configuration problem, not something I can fix in code anyway.

Sorry I needed to take care of my kids. What is the best way to check ?

I run feature:install openhab-transport-serial in the console… Can I check there something else ?

Until now I just could check on my OH server host (not the docker container):

clement@NAS:~$ ./bled112_scanner.py -p /dev/ttyNET0
================================================================
BLED112 Scanner for Python v2013-04-07
================================================================
Serial port:	/dev/ttyNET0
Baud rate:	115200
Scan interval:	200 (250.00 ms)
Scan window:	200 (250.00 ms)
Scan type:	Passive
UUID filters:	None
MAC filter(s):	None
RSSI filter:	None
Display fields:	- Time
		- RSSI
		- Packet type
		- Sender MAC
		- Address type
		- Bond status
		- Payload data
Friendly mode:	Disabled
----------------------------------------------------------------
Starting scan for BLE advertisements...

Still fighting with the socat thing because I will need to get other bluetooth device, not only for presence.

Not sure what I will do further… I am not sure docker see correctly the socat device passed as device to the container.

After several try I face 2 issues.

  1. Make socat run in docker either by sharing device (not possible because socat use symlink). I tried with privileged to true to eliminate any isolated issue. I try to make run as a service. But exemple was given with Systemd which is a pain to make running in docker at least for me.
  2. Let’s say I went to the docker machine and manually start socat with the necessary configuration. I tried to run the Bluetooth python tool to check it works. It is looking good. But then come openhab third party Bluetooth binding where I set the device path directly instead of general regex. But the adapter I manually add stay offline. I can share the log when back to my computer.

I am taking any advice, really interested to make raspberry pi gateway using ser2ner…

PS: Location exact is only a bonus. Main purpose is like the first post shared, to be able to have deported Bluetooth or zwave using raspberry pi.

If you want to run this inside Docker you are going to have to get good at building your own custom Docker images. If you are using the official OH dinner image you need to added installation of all the stuff you need and add starting the socat stuff to entrypoint.sh. Docker images, almost as a rule, do not include systemd or upstart.

I firmly believe that pretty much every other suggestion in this thread will be less work to get working than getting socat and the Bluetooth binding working in Docker.

I believe as well that the other solutions are easier. But won’t work if I want to connect other devices.

But with perseverance I now able to run socat and openhab thanks to supervisord in the container. Openhab run but cannot connect to the bluetooth when this works within the container:

root@NAS:/openhab# ./bled112_scanner.py -p /dev/ttyNET0
================================================================
BLED112 Scanner for Python v2013-04-07
================================================================
Serial port:	/dev/ttyNET0
Baud rate:	115200
Scan interval:	200 (250.00 ms)
Scan window:	200 (250.00 ms)
Scan type:	Passive
UUID filters:	None
MAC filter(s):	None
RSSI filter:	None
Display fields:	- Time
		- RSSI
		- Packet type
		- Sender MAC
		- Address type
		- Bond status
		- Payload data
Friendly mode:	Disabled
----------------------------------------------------------------
Starting scan for BLE advertisements...

Does not find anything but at least no errors.

And I have this in the container:

root@NAS:/openhab# ls -al /dev/ttyNET0
lrwxrwxrwx 1 root root 10 Jun 26 01:59 /dev/ttyNET0 -> /dev/pts/0

while writing it I realise it creates it under root:root… I specified openhab:dialout in socat command there: (still work if I login as openhab and run ./bled112_scanner.py -p /dev/ttyNET0

[program:socat]
command=/usr/bin/socat -d -d pty,link=/dev/ttyNET0,raw,user=openhab,group=dialout,mode=777 tcp:192.168.178.84:3001
autorestart=true

But on openhab side with the third party bluetooth binding I get the following:

01:52:48.903 [WARN ] [er.transport.bluegiga.BluegigaHandler] - Timeout has happened while sending a transaction, retry one more time: BlueGigaEndProcedureCommand
01:52:58.904 [WARN ] [er.transport.bluegiga.BluegigaHandler] - Timeout has happened second time, giving up: BlueGigaEndProcedureCommand
01:52:58.931 [WARN ] [er.transport.bluegiga.BluegigaFactory] - Error occurred while creating a new adapter for port: /dev/ttyNET0, Could not initialize blugiga handler for port: /dev/ttyNET0

On the pi the netstat command gives

tcp6     233      0 192.168.178.84:3001     192.168.178.29:35734    ESTABLISHED -

Going forward…

???

reelActive has a central server and clients. Each client uses its own BT device and reports the signal strength of all the BT devices that it sees. The server looks at all the reports from all the clients and reports to OH which client has the strongest signal and therefore telling you which room the BT device is in. It solves EXACTLY your problem.

Similarly, sensorReporter is designed to run on more than one Raspberry Pi (or other computers) and report to OH when it can see a BT device. Slight modifications will let it report the RSSI (I’d even make the modifications for you). So sensorReporter nearly solves EXACTLY your problem, though determining which RPi the BT device is closest to will have to be done by Rules.

Somewhat differently, FIND triangulates the location of your phone based on the signal strength of all the wifi APs the phone can see. So this solves your problem, but uses wifi instead of BT.

There is no limitation to connecting to only one BT device in ANY of these solutions.

Just so you know guys @rlkoshak @clempat, the 3rd party bluetooth binding is supposed to do indoor positioning as well. It accumulates RSSI readings from all adapters and calculates shortest distance from bt device to installed adapters. Obviously you will need to have an adapter in each room.

What kind of adapters you are using? Generic USB or BlueGiga?

Do you really use a BlueGiga Adapter? and did you get data on your raspi zero? I have the strong feeling, that the onboard bluetooth ist a generic bluetooth device and with this ser2net will not work.

Sorry I meant for exemple I have a Bluetooth temperature Sensor (Xiaomi). I would be interested to get the data from it instead of the signal and the presence. And for this reason I would need to use the Bluetooth binding solution.

I think you are both right and point on the right direction. I use the built in raspberry pi Bluetooth :upside_down_face:

Damn I wish I would have it working. It is the only limitation I found yet to move my system to openhab.

I’m aware of that. I’m also aware of the challenges of getting it to work in Docker, hence my recommendation.

@vkolotov As you are here. First thanks for the awesome work you did for the Bluetooth binding. Here is how I stand now:
I have a raspberry pi zero with ser2net exposing the serial I think is the built in Bluetooth.
I have a machine with docker and running socat and openhab. I made a custom image for that here: https://hub.docker.com/r/clempat/openhab-socat/
I see /dev/tryNET0 as said in my last message. Is the 3rd party Bluetooth integration a solution for me or I need to look somewhere else ?

hi @clempat, the internal bluetooth adapter is not serial port based device (unlike BlueGiga devices). You will have to use something different rather than ser2net, that allows you to create a virtual usb port over ip.

@Dibbler42, has created a manual how to do so: Forwarding of serial and USB ports over the network to openHAB

If you had a BluGiga adapter, then you would be able to use ser2net.

@clempat Than you can use the usbip solution from my tutorial. The docker parts ist this still open

Great I will try it tonight. And share again… Thanks for the help sorry for spamming you :slight_smile:

you are welcome :slight_smile:

Did you finally have success? i just bought as pi zero W, but did not manage to propagate the bluetooth to the central openHAb instance.

Hello, i could not have it work. As deported solution I did have one success with zwave but not the Bluetooth. I don’t remember where I was blocking. I am now using mqtt solutions…