Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPS30 to mosquitto socket error #36

Closed
taarhaug opened this issue Dec 7, 2022 · 8 comments
Closed

SPS30 to mosquitto socket error #36

taarhaug opened this issue Dec 7, 2022 · 8 comments
Labels
question Further information is requested

Comments

@taarhaug
Copy link

taarhaug commented Dec 7, 2022

Hei,

Using latest version of pms on ubuntu, I cannot make the mqtt connection to mosquitto 1.4.15 work:
pms -m SPS30 -n 1 -i 10 -s /dev/ttyUSB1 mqtt --mqtt-host localhost -t "test" throws no error, but I cannot subscribe to the feed.

mosquitto log indicates socket error:

1670442753: New client connected from 192.168.50.100 as test (c1, k60).
1670442769: Socket error on client test, disconnecting.

I have used pms serial and influx successfully for a long time, but for mqtt I could not get pms to work.

pms installed with pip: python3 -m pip install pypms[mqtt,influxdb]

@avaldebe
Copy link
Owner

avaldebe commented Dec 8, 2022

what is the port of your local MQTT server? The CLI uses port 1883 by default.

@avaldebe avaldebe added the question Further information is requested label Dec 8, 2022
@taarhaug
Copy link
Author

taarhaug commented Dec 8, 2022 via email

@avaldebe
Copy link
Owner

avaldebe commented Dec 8, 2022

I do not know, what is the version of the Python MQTT library? (pip show paho-mqtt)
Is that version compatible with your MQTT server?

@taarhaug
Copy link
Author

taarhaug commented Dec 8, 2022

1.6.1. I use this client for a MQTT generator that works nicely with mosquitto. I reproduced the error on a RPi running raspbian.

@avaldebe
Copy link
Owner

avaldebe commented Dec 8, 2022

I have no idea what the problem could be. I just released a new version of the library and CLI, but I do not think that updating would help. BTW, what version of python and PyPMS are you using?

@taarhaug
Copy link
Author

taarhaug commented Dec 8, 2022

pypms 0.6.2, python 3.6.9 on ubuntu 18.04
pypms 0.6.2, python 3.7.3 on raspbian

@taarhaug
Copy link
Author

taarhaug commented Dec 8, 2022

Oddest thing, Topic is critical here:

I collect data and publish:
pms -m SPS30 -n 1 -i 10 -s /dev/ttyUSB1 mqtt --mqtt-host localhost --mqtt-port 1883 -t "home/dust/SPS30"

I try to collect with mosquitto:
mosquitto_sub -t "home/dust/SPS30"

This collects nothing, but this does:

mosquitto_sub -t "home/#" (or even "home/dust/#, "home/+/#")

Not sure why. I can't see Topic sent but I check that mosquitto[_sub,_pub] works as expected with Topic publish and subscribe.

Sent data looks like this:

true
PM1
sensor,unit,concentration
SPS30
μg/m3
1.107303261756897
PM2.5
sensor,unit,concentration
SPS30
μg/m3
1.7731504440307617
PM4
sensor,unit,concentration
SPS30
μg/m3
2.2605395317077637
PM10
sensor,unit,concentration
SPS30
μg/m3
2.3580174446105957
1.2040939331054688
1.5197216272354126
1.7191693782806396
1.759059190750122
false

I guess the numbers at the end are number concentrations and typical particle size. But which is which?

SDS198 seem to get a double concentration entry in the data:

true
PM100
sensor,unit,concentration
SDS198
μg/m3
7
7
false

@taarhaug
Copy link
Author

taarhaug commented Dec 8, 2022

I found the issue. The way data is sent to mqtt, you cannot expect to publish and subscribe to the same topic (like you would find in most examples). I found it by verbose subscription:

$ mosquitto_sub -v -t "#"
home/dust/SDS198/$online false
home/dust/SDS198/pm100/$type PM100
home/dust/SDS198/pm100/$properties sensor,unit,concentration
home/dust/SDS198/pm100/sensor SDS198
home/dust/SDS198/pm100/unit μg/m3
home/dust/SDS198/pm100/concentration 2
home/dust/SDS198/$online true

My apologies, I've should have read up more on MQTT before I started testing.

@taarhaug taarhaug closed this as completed Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants