I'm tinkering a camera device with a pir motion sensor for the door.
Looks good so far. There's only one problem.
I use a script that reads the signal from the pir sensor and when motion is detected it publishes a message to the mosquitto mqtt broker. This works also fine but not very reliable.
I use the mosquitto_pub command delivered with mosquitto.
When this is working the log shows this:
no motion no motion motion detected Client (null) sending CONNECT Client (null) received CONNACK (0) Client (null) sending PUBLISH (d0, q1, r0, m1, 'raspis/entrycam/motion', ... (3 bytes)) Client (null) received PUBACK (Mid: 1, RC:0) Client (null) sending DISCONNECT no motion no motion
but sometimes I see this
no motion no motion motion detected Error: Connection refused no motion no motion
I do not understand why this happens. When this happens it takes some time.
Then it works again as expected until it fails again after uncertain time.
First I thought I had some mosquitto configuration, that there is some limit there but I do not see what is misconfigured.
I also do not see anything in the mosquitto logs, when this happens. The connection to the device is stable. I'm connected via ssh and this is stable.
The command I use is :
mosquitto_pub -h broker -t raspis/entrycam/motion -u user -P password -m 'yes' -q 1 -d
Help is very appreciated.
Thanks in advance!