Skip to content

Commit

Permalink
moved bme280 into sensors/, fixed missing import
Browse files Browse the repository at this point in the history
  • Loading branch information
JavanXD committed May 1, 2019
1 parent 289b708 commit d0ffe85
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import RPi.GPIO as GPIO

from read_bme680 import measure_bme680, initBME680FromMain
from read_bme280 import measure_bme280
from read_ds18b20 import measure_temperature
from read_hx711 import measure_weight, compensate_temperature
from read_dht import measure_dht
Expand Down
21 changes: 8 additions & 13 deletions read_bme280.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
# See file LICENSE or go to http://creativecommons.org/licenses/by-nc-sa/3.0/ for full license details.

import time
from bme280 import readBME280All #http://bit.ly/bme280py

# global vars
from sensors.bme280 import readBME280All #http://bit.ly/bme280py

def measure_bme280(ts_sensor):
fields = {}
Expand All @@ -14,16 +12,13 @@ def measure_bme280(ts_sensor):

# ThingSpeak fields
# Create returned dict if ts-field is defined
if 'ts_field_temperature' in ts_sensor:
fields[ts_sensor["ts_field_temperature"]] = temperature
if 'ts_field_humidity' in ts_sensor:
fields[ts_sensor["ts_field_humidity"]] = humidity
if 'ts_field_air_pressure' in ts_sensor:
fields[ts_sensor["ts_field_air_pressure"]] = pressure
if 'ts_field_temperature' in ts_sensor and isinstance(temperature, (int, float)):
fields[ts_sensor["ts_field_temperature"]] = round(temperature, 2)
if 'ts_field_humidity' in ts_sensor and isinstance(humidity, (int, float)):
fields[ts_sensor["ts_field_humidity"]] = round(humidity, 2)
if 'ts_field_air_pressure' in ts_sensor and isinstance(pressure, (int, float)):
fields[ts_sensor["ts_field_air_pressure"]] = round(pressure, 2)
except OSError:
print('No BME280 Sensor connected')
print('No BME280 Sensor connected.')

return fields
if __name__ == '__main__':
while True:
time.sleep(0.5)
File renamed without changes.

0 comments on commit d0ffe85

Please sign in to comment.