-
Notifications
You must be signed in to change notification settings - Fork 0
Service File Configuration
Important
Start the Service File Configuration only after all the InfluxDB and Grafana Configuration steps have been completed.
-
To ensure the influxdb-multisensor.py script runs even if the device reboots, we will use a service file.
sudo nano /lib/systemd/system/influxdb-multisensor.service
-
Copy and paste the contents from
influxdb-multisensor.service
[found within the RPi-IoT folder or here: Link] into the new service file making sure to check theWorkingDirectory
andExecStart
file path locations match the location of the "multisensors" folder. It should look something like this:[Unit] Description=Vivarium Monitor After=network-online.target [Service] Type=simple Restart=always RestartSec=60 WorkingDirectory=/home/pi/RPi-IoT/multisensors/ ExecStart=/usr/bin/python3 /home/pi/RPi-IoT/multisensors/influxdb-multisensor.py [Install] WantedBy=multi-user.target
Save and close: Ctrl+X -> Y -> hit enter
-
Close the terminal window where the python script was printing realtime sensor values or hit Ctrl+C to interrupt the script
-
Enable the service file and reload all service files
sudo systemctl enable influxdb-multisensor.service sudo systemctl daemon-reload sudo systemctl start influxdb-multisensor.service
-
You can test if the program restarts if the Pi loses power and reboots
sudo shutdown -r now
Once the Pi boots up:
sudo systemctl status influxdb-multisensor.service
You should see something like this:
You can also open a browser and navigate to http://localhost:3000/ to check if grafana is receiving sensor values.
Once the above steps are completed, you can proceed to Cloudflare Configuration