ayeks / bme680_to_influxdb

Simple script that sends your BME680 temp, pressure, humidity and gas sensor data to InfluxDB.
MIT License
23 stars 16 forks source link

Start on boot not working #10

Closed ngtrthanh closed 3 years ago

ngtrthanh commented 3 years ago

Hi

I try start on boot by several ways but not work.

I can run with nohup successfully rc.but local and service not work

sudo systemctl status bme680

● bme680.service - bme680 sensor Service Loaded: loaded (/lib/systemd/system/bme680.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2020-11-29 09:18:43 +07; 13s ago Process: 1026 ExecStart=/usr/bin/python3 /home/pi/senddata.py /home/pi/config.ini (code=exited, status=1/FAILURE) Main PID: 1026 (code=exited, status=1/FAILURE)

Nov 29 09:18:43 raspberrypi systemd[1]: Started bme680 sensor Service. Nov 29 09:18:43 raspberrypi python3[1026]: Traceback (most recent call last): Nov 29 09:18:43 raspberrypi python3[1026]: File "/home/pi/senddata.py", line 5, in Nov 29 09:18:43 raspberrypi python3[1026]: from influxdb import InfluxDBClient # for collecting data Nov 29 09:18:43 raspberrypi python3[1026]: ModuleNotFoundError: No module named 'influxdb' Nov 29 09:18:43 raspberrypi systemd[1]: bme680.service: Main process exited, code=exited, status=1/FAILURE Nov 29 09:18:43 raspberrypi systemd[1]: bme680.service: Failed with result 'exit-code'.

could you have a look?

ngtrthanh commented 3 years ago

Add

User=pi Group=pi

to service file and it's OK.

[Unit] Description=bme680 sensor Service After=multi-user.target

[Service] Type=idle ExecStart=python3 /home/pi/senddata.py "/home/pi/config.ini" User=pi Group=pi

[Install] WantedBy=multi-user.target