[presence] Reliable, Multi-User, Distributed Bluetooth Occupancy/Presence Detection

I have tried “all” combinations:
mqtt_publisher_identity=sala
mqtt_publisher_identity=‘sala’
mqtt_publisher_identity=“sala”

mqtt_publisher_identity= sala
mqtt_publisher_identity= ‘sala’
mqtt_publisher_identity= “sala”

None is working, i’m out of ideias, from what i know order of the declaration is irrelevant but, can it be?

---------------------------

MOSQUITTO PREFERENCES

---------------------------

IP ADDRESS OF MQTT BROKER

mqtt_address=myipwithoutquotation

MQTT BROKER USERNAME (OR BLANK FOR NONE)

mqtt_user=myyserwithoutquotation

MQTT BROKER PASSWORD (OR BLANK FOR NONE)

mqtt_password=mypasswithoutquotation

MQTT PUBLISH TOPIC ROOT

mqtt_topicpath=location/monitor

PUBLISHER IDENTITY

mqtt_publisher_identity=“sala”

PUBLISHER IDENTITY

mqtt_publisher_identity=’’

MQTT PORT

mqtt_port=‘1884’

MQTT CERTIFICATE FILE

mqtt_certificate_path=’’

Hello

1 - please see the big blue box at the top of this (and every) page. Formatting your code snippets correctly will allow others to help you more easily.

2 - you seem to have two entries for mqtt_publisher_identity in the above? Please post your preferences file in full (using the tip set out in the blue box). For example, here is one of mine:

# ---------------------------
#								
# MOSQUITTO PREFERENCES
#								
# ---------------------------

# IP ADDRESS OF MQTT BROKER
mqtt_address=192.168.XXX.XXX

# MQTT BROKER USERNAME (OR BLANK FOR NONE)
mqtt_user=XXXXX

# MQTT BROKER PASSWORD (OR BLANK FOR NONE)
mqtt_password=XXXXX

# MQTT PUBLISH TOPIC ROOT
mqtt_topicpath=presence

# PUBLISHER IDENTITY
mqtt_publisher_identity='XXXXX'

# MQTT PORT
mqtt_port='1883'

That is because i was trying more and more options and copy some variables.

I also tried to remove mqtt_topicpath variable and included everything on the mqtt_publisher_identity with no luck.

At the end of the day I will try one by one adding each variable to see if i can come up with something.

Also this is a fresh installation on a new pie zero w and on a new jessie install, brand new card running as a service with this parameters and pipper:
-d 1>&2 >> logging_output.log

In this example file, you have the publisher identity variable defined twice. Is this a direct copy paste?

It was and i have corrected it, like I said before I’m trying everything, also changing the variable location (line) and the only combination that worked is with it on the first line, any other place and it gives me the error.

It’s working so I can’t complain for using a program that @andrewjfreyer have dedicated his personal time to share with us, So once more thank you.

@jpm hit me up on discord if you’re still having issues with this. We’ll get it figured out.

I’ve very excited to give this a go, I do however have a couple of questions.

I currently have my Pi Zero W running DietPi and setup for MiFlora integration, do you envisage any issues installing Presence on DietPi as oppose to Jessie Lite? Also DietPi has its own ‘software library’ where it lists Mosquitto as an option. I’m again hoping this will be work as opposed to installing another version of Mosquitto.

Thoughts?

I haven’t used that distro, so I’m not sure. I would say that this does require full and constant access to the BT hardware, so using with miflora is probably not going to be successful.

Oh that’s a shame. Still with the cost of a Pi Zero W what they are I can afford to have a couple around the house, just wanted to limit the amount of things that were plugged in.

Very like this project, but after using, found that no days, the home network can not be used all, restart the network can, back off zero W, the next few days the network is very normal! It’s very strange!

Yes, Bluetooth interferes with many 2.4GHz networks, especially broadcast from routers that do not have robust interference mitigation. Try the monitor script beta referenced in this thread, I think you’ll find that interference is dramatically reduced.

Yeah, it’s unfortunate. But, that is the nature of a bluetooth sensor - both miflora and presence and monitor need to have access to the BT hardware in order to promptly report changes. They can all coexist, but reporting delays for each would be substantial.

Ok I took the plunge and setup the system on a spare pi 3 until I get hold of another Pi Zero W. All installed fine until I ran sudo service bluetooth status then I receive the follow error:

Aug 07 19:24:16 raspberrypi systemd[1]: Starting Bluetooth service...
Aug 07 19:24:16 raspberrypi bluetoothd[451]: Bluetooth daemon 5.43
Aug 07 19:24:16 raspberrypi systemd[1]: Started Bluetooth service.
Aug 07 19:24:16 raspberrypi bluetoothd[451]: Starting SDP server
Aug 07 19:24:16 raspberrypi bluetoothd[451]: Bluetooth management interface 1.14 initialized
Aug 07 19:24:16 raspberrypi bluetoothd[451]: Failed to obtain handles for "Service Changed" characteristic
Aug 07 19:24:16 raspberrypi bluetoothd[451]: Sap driver initialization failed.
Aug 07 19:24:16 raspberrypi bluetoothd[451]: sap-server: Operation not permitted (1)

Completed the setup and not seeing anything in mqttfx so I’m guessing the bluetooth error is the issue. I didn’t install optional: BLUEZ UPGRADE as mentioned as this came after the status check.

Any ideas how to fix?

UPDATE: I see from another post on here that this error can be ignored, just need to work out why I’m not seeing anything published to MQTTfx.

@apt Hi! Are you running presence or monitor?

Presence. It seems to be working, I don’t think I was giving it long enough to report via MQTT. How often should I see an MQTT payload sent? Is it only when theres a definite change in state?

One of my devices it reporting quite often (every 30 seconds) the other has shown twice and each time it says ‘unknown device’ and then doesn’t show again. rebooted pi and device, still the same.

1 Like

The behavior of the script depends on the command line options at launch. Also, the distance separating your Bluetooth devices from the server running the script. If your second device is much farther away, or has a weaker Bluetooth signal, or has a low battery, the present script may determine that it is away more frequently than other Bluetooth devices in your home.

Or see who visit the missis when you are out :rofl:

I have it running on my DietPi ZW and works great. But that’s the only thing other than mosquitto on it.

quick edit: I’m doing nothing fancy with it. Just gathering two points, my RPi 3B on DietPi and my RPi ZW on DietPi, and making sure both are reading 100% based on the simple example on the GitHub Wiki.

2 Likes