You shouldn’t get any output when you start it, however that doesn’t necessarily mean it’s working.
If it is working, you should see MQTT messages being sent to your broker, or sensors being updated in Home Assistant (if you have configured them) etc.
If it doesn’t appear to be working, you can check the logs of the service by running journalctl -u envlogger.service. You can also stop the service (same command as starting it, but replace start with stop) and then run the same python3 command from the service file manually to see what output you get.
Thank you. I tried uninstalling paho but could not find a way. So I just ran pip3 install paho-mqtt
Restarted pi
Now, this is what I get from the logger:
-- Logs begin at Mon 2020-03-16 19:20:23 EDT, end at Mon 2020-03-16 19:46:57 EDT. --
Mar 16 19:20:50 raspberrypi systemd[1]: Started Enviro+ MQTT Logger.
Mar 16 19:21:09 raspberrypi python3[325]: Traceback (most recent call last):
Mar 16 19:21:09 raspberrypi python3[325]: File "/usr/src/enviroplus-mqtt/src/main.py", line 63, in <module>
Mar 16 19:21:09 raspberrypi python3[325]: main()
Mar 16 19:21:09 raspberrypi python3[325]: File "/usr/src/enviroplus-mqtt/src/main.py", line 33, in main
Mar 16 19:21:09 raspberrypi python3[325]: num_samples=args["interval"]
Mar 16 19:21:09 raspberrypi python3[325]: File "/usr/src/enviroplus-mqtt/src/logger.py", line 27, in __init__
Mar 16 19:21:09 raspberrypi python3[325]: self.client.connect(host, port)
Mar 16 19:21:09 raspberrypi python3[325]: File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 937, in connect
Mar 16 19:21:09 raspberrypi python3[325]: return self.reconnect()
Mar 16 19:21:09 raspberrypi python3[325]: File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1071, in reconnect
Mar 16 19:21:09 raspberrypi python3[325]: sock = self._create_socket_connection()
Mar 16 19:21:09 raspberrypi python3[325]: File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3522, in _create_socket_connection
Mar 16 19:21:09 raspberrypi python3[325]: return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
Mar 16 19:21:09 raspberrypi python3[325]: File "/usr/lib/python3.7/socket.py", line 727, in create_connection
Mar 16 19:21:09 raspberrypi python3[325]: raise err
Mar 16 19:21:09 raspberrypi python3[325]: File "/usr/lib/python3.7/socket.py", line 716, in create_connection
Mar 16 19:21:09 raspberrypi python3[325]: sock.connect(sa)
Mar 16 19:21:09 raspberrypi python3[325]: OSError: [Errno 101] Network is unreachable
Mar 16 19:21:10 raspberrypi systemd[1]: envlogger.service: Main process exited, code=exited, status=1/FAILURE
Mar 16 19:21:10 raspberrypi systemd[1]: envlogger.service: Failed with result 'exit-code'.
Mar 16 19:21:10 raspberrypi systemd[1]: envlogger.service: Service RestartSec=100ms expired, scheduling restart.
Mar 16 19:21:10 raspberrypi systemd[1]: envlogger.service: Scheduled restart job, restart counter is at 1.
Mar 16 19:21:10 raspberrypi systemd[1]: Stopped Enviro+ MQTT Logger.
Mar 16 19:21:10 raspberrypi systemd[1]: Started Enviro+ MQTT Logger.
Don’t know what’s happening? Any help is greatly appreciated
This suggests the device doesn’t have network access, or the MQTT host address you are trying to connect to is not reachable on the same network as the Enviro+ Pi.
Actually, I am using IP, because I am connecting to a local server. Let me research and see if I can find a solution.
BTW, if I run: python3 /usr/src/enviroplus-mqtt/src/main.py -h 192.168.1.xxx -p 1883 -U xxxxxx -P xxxxx
It never ends. I have to ^c to stop it. When I do that, every time, I get this:
^CTraceback (most recent call last):
File "/usr/src/enviroplus-mqtt/src/main.py", line 63, in <module>
main()
File "/usr/src/enviroplus-mqtt/src/main.py", line 59, in main
time.sleep(sleep_duration)
KeyboardInterrupt
Yes, that’s what should happen - it doesn’t log to standard out unless there is an error of some sort. If you see no output that suggests it has connected successfully, and your MQTT server should start to receive messages after 30 seconds or so.
Maybe you should still paste the output of cat /etc/systemd/system/envlogger.service - it sounds like the logger works fine if you manually invoke it, so something must be wrong with the service configuration.
I have no idea why that -u is in the example service file… It should be removed.
It looks like Pimoroni have just added some code for accessing the sound sensor, and there’s no reason why it couldn’t be used to send sound data back via mqtt - but you would have to write that code yourself and add it to enviroplus-mqtt, there’s no support for sound reporting at the moment.
Hello Sam,
I try to download your enviro case as STL files but it only downloads as one file and i dont know if it will print 2 pieces or only one. Is it possible to receive 2 separated STL files? Thx in advance
I get the following errors:
– Logs begin at Tue 2020-03-24 16:44:46 EET, end at Tue 2020-03-24 19:33:55 EET. –
Mar 24 16:45:09 raspberrypi systemd[1]: Started Enviro+ MQTT Logger.
Mar 24 16:45:09 raspberrypi systemd[366]: envlogger.service: Changing to the requested working directory failed: No such file or dire
Mar 24 16:45:09 raspberrypi systemd[366]: envlogger.service: Failed at step CHDIR spawning /usr/bin/python3: No such file or director
Mar 24 16:45:10 raspberrypi systemd[1]: envlogger.service: Main process exited, code=exited, status=200/CHDIR
Mar 24 16:45:10 raspberrypi systemd[1]: envlogger.service: Failed with result ‘exit-code’.
Mar 24 16:45:11 raspberrypi systemd[1]: envlogger.service: Service RestartSec=100ms expired, scheduling restart.
Mar 24 16:45:11 raspberrypi systemd[1]: envlogger.service: Scheduled restart job, restart counter is at 1.
Mar 24 16:45:11 raspberrypi systemd[1]: Stopped Enviro+ MQTT Logger.
Mar 24 16:45:11 raspberrypi systemd[1]: Started Enviro+ MQTT Logger.
Mar 24 16:45:12 raspberrypi systemd[391]: envlogger.service: Changing to the requested working directory failed: No such file or dire
Mar 24 16:45:12 raspberrypi systemd[391]: envlogger.service: Failed at step CHDIR spawning /usr/bin/python3: No such file or director
Mar 24 16:45:12 raspberrypi systemd[1]: envlogger.service: Main process exited, code=exited, status=200/CHDIR
Mar 24 16:45:12 raspberrypi systemd[1]: envlogger.service: Failed with result ‘exit-code’.
Mar 24 16:45:13 raspberrypi systemd[1]: envlogger.service: Service RestartSec=100ms expired, scheduling restart.
Mar 24 16:45:13 raspberrypi systemd[1]: envlogger.service: Scheduled restart job, restart counter is at 2.
Mar 24 16:45:13 raspberrypi systemd[1]: Stopped Enviro+ MQTT Logger.
Mar 24 16:45:13 raspberrypi systemd[1]: Started Enviro+ MQTT Logger.
Mar 24 16:45:13 raspberrypi systemd[405]: envlogger.service: Changing to the requested working directory failed: No such file or dire
Mar 24 16:45:13 raspberrypi systemd[405]: envlogger.service: Failed at step CHDIR spawning /usr/bin/python3: No such file or director
Mar 24 16:45:13 raspberrypi systemd[1]: envlogger.service: Main process exited, code=exited, status=200/CHDIR
Mar 24 16:45:13 raspberrypi systemd[1]: envlogger.service: Failed with result ‘exit-code’.
Have you tried loading the STL into your slicing software to see how it will print? You can also try installing Fusion 360 and opening the design in that - then you can export it however you want.
Can you paste the output of running cat /etc/systemd/system/envlogger.service and /usr/bin/python3 -V ?
Based on these two lines from your log file:
Mar 24 16:45:09 raspberrypi systemd[366]: envlogger.service: Changing to the requested working directory failed: No such file or dire
Mar 24 16:45:09 raspberrypi systemd[366]: envlogger.service: Failed at step CHDIR spawning /usr/bin/python3: No such file or director
I suspect you either don’t have Python 3 installed at /usr/bin/python3, or the directory you have specified as the WorkingDirectory in the service file does not exist.