Skip to content

Commit

Permalink
Return sea level in new reading key
Browse files Browse the repository at this point in the history
  • Loading branch information
sjefferson99 committed Apr 25, 2024
1 parent f4118ac commit b0163b6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions enviro/boards/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,9 @@ def get_sensor_readings(seconds_since_last, is_usb_power):
# Adjust pressure to calculated sea level value if set to in config
pressure = bme280_data[1] / 100.0
temperature = bme280_data[0]

if config.sea_level_pressure:
logging.info(f" - recorded temperature: {temperature}")
logging.info(f" - recorded pressure: {pressure}")
pressure = round(helpers.get_sea_level_pressure(pressure, temperature, config.height_above_sea_level), 2)
logging.info(f" - calculated mean sea level pressure: {pressure}")

from ucollections import OrderedDict
return OrderedDict({
readings = OrderedDict({
"temperature": round(temperature, 2),
"humidity": round(bme280_data[2], 2),
"pressure": round(pressure, 2),
Expand All @@ -211,3 +205,12 @@ def get_sensor_readings(seconds_since_last, is_usb_power):
"rain_per_second": rain_per_second,
"wind_direction": wind_direction()
})

if config.sea_level_pressure:
logging.info(f" - recorded temperature: {temperature}")
logging.info(f" - recorded pressure: {pressure}")
sea_level_pressure = round(helpers.get_sea_level_pressure(pressure, temperature, config.height_above_sea_level), 2)
logging.info(f" - calculated mean sea level pressure: {sea_level_pressure}")
readings["sea_level_pressure"] = round(sea_level_pressure, 2)

return readings

0 comments on commit b0163b6

Please sign in to comment.