Read sensor data from a bme280 and upload to InfluxDB
Tested with Raspbian 10 (buster) on Raspberry Pi Zero W with Adafruit BME280 hooked up over I2C. Should be reasonably easy to adapt to different sensor types.
-
Install InfluxDB and the python InfluxDB client:
sudo apt-get install influxdb influxdb-client python3-influxdb
-
Install the BME280 and required libraries, and pytest:
sudo pip3 install adafruit-circuitpython-bme280 pytest
-
Clone this repo someplace.
-
Edit configuration in
sensor_config.py
-
Edit
ExecStart
inbme280-logger.service
to point to the path to the logger service in the repo, then install and launchbme280-logger.service
:sudo cp bme280-logger.service /etc/systemd/system sudo systemctl start bme280-logger.service sudo systemctl enable bme280-logger.service
To test on a system without InfluxDB or a real BME280, use pytest:
python3 -m pytest bme280-logger.py