Hi,
I had a Pi 4 with the Enviro+ sensor in one of my server rooms pushing data into Mosquitto which was then read by PRTG. This unit as been happily doing it’s job for the last couple of years but the SD card died so I’ve rebuilt it with a new SD card only to find some of the commands contained within the mqtt-all.py example script are now deprecated within the latest version of Pi OS. Please see output below, I wonder if there is someone more adept at Pi OS who can help me get this working again?
Thanks,
Nick
(pimoroni) climate@raspberrypi-Pullinger:~/enviroplus-python/examples $ ./mqtt-all.py
mqtt-all.py - Reads Enviro plus data and sends over mqtt.
broker: localhost
client_id: raspi-10000000269360ea
port: 1883
topic: enviroplus
tls: False
username: None
password: None
Press Ctrl+C to exit!
/home/climate/enviroplus-python/examples/./mqtt-all.py:214: DeprecationWarning: Callback API version 1 is deprecated, update to latest version
mqtt_client = mqtt.Client(client_id=device_id)
Traceback (most recent call last):
File “/home/climate/enviroplus-python/examples/./mqtt-all.py”, line 285, in
main()
File “/home/climate/enviroplus-python/examples/./mqtt-all.py”, line 226, in main
mqtt_client.connect(args.broker, port=args.port)
File “/home/climate/.virtualenvs/pimoroni/lib/python3.11/site-packages/paho/mqtt/client.py”, line 1435, in connect
return self.reconnect()
^^^^^^^^^^^^^^^^
File “/home/climate/.virtualenvs/pimoroni/lib/python3.11/site-packages/paho/mqtt/client.py”, line 1598, in reconnect
self._sock = self._create_socket()
^^^^^^^^^^^^^^^^^^^^^
File “/home/climate/.virtualenvs/pimoroni/lib/python3.11/site-packages/paho/mqtt/client.py”, line 4609, in _create_socket
sock = self._create_socket_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/climate/.virtualenvs/pimoroni/lib/python3.11/site-packages/paho/mqtt/client.py”, line 4640, in _create_socket_connection
return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/socket.py”, line 851, in create_connection
raise exceptions[0]
File “/usr/lib/python3.11/socket.py”, line 836, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused