Created
March 29, 2021 09:26
-
-
Save derpeter/7027588dd90a3f9228b66ca0c4c9d07d to your computer and use it in GitHub Desktop.
BME280 telegraf exec plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time | |
try: | |
from smbus2 import SMBus | |
except ImportError: | |
from smbus import SMBus | |
from bme280 import BME280 | |
# Initialise the BME280 | |
bus = SMBus(0) | |
bme280 = BME280(i2c_dev=bus) | |
temperature = bme280.get_temperature() | |
pressure = bme280.get_pressure() | |
humidity = bme280.get_humidity() | |
print('BME280,sensor=bme280 celsius={:05.2f},hPa={:05.2f},humidity={:02.2f}'.format(temperature, pressure, humidity)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses https://github.com/pimoroni/bme280-python/ and smbus2 to read values from an BME280 sensor and prints out influx line format.
you might wan't to add
chgrp telegraf /dev/i2c-0
to e.g. rc.local