Remote monitoring and notifications for temperature, pressure, humidity and air quality measurement using BME 680
This project shows how to monitor and send alert notifctaions for high accuracy gas, pressume, humidity and temperatue using BME 680 sesnsor and Hologram Nova.
Install Python library required from BME 680 breakout as show in Pimoroni portal article.
Things used in this project:
Hardware components:
- Raspberry Pi Zero
- BME 680 Sensor
- Hologram SIM
Software Apps:
- Python
- Hologram CLI
The installation instructions for Hologram SIM are provided here
First establish a cellular connection using the credentials that uses a devicekey obtained from Hologram dashboard and the import BME 680 and time libarries. As described in the Pimoroni portal article,
sensor = bme680.BME680()
creates an instance of the sensor and it is used for taking the readings for pressure, humidity etc.#!/usr/bin/env python
import bme680
import time
from Hologram.HologramCloud import HologramCloud
import datetime
import logging
# Provide Hologram device key
credentials = {'devicekey': 'xxxxxxxx'}
hologram = HologramCloud(credentials, network='cellular')
try:
sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
except IOError:
sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)
sensor.set_humidity_oversample(bme680.OS_2X)
sensor.set_pressure_oversample(bme680.OS_4X)
sensor.set_temperature_oversample(bme680.OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3)
sensor.set_gas_status(bme680.ENABLE_GAS_MEAS)
sensor.set_gas_heater_temperature(320)
sensor.set_gas_heater_duration(150)
sensor.select_gas_heater_profile(0)
Gas, temperature, pressure, humidity values can be obtained using sensor.data.gas_resistance, sensor.data.temperature
, sensor.data.pressure
, and sensor.data.humidity.
After comparing the meausre values such as gas resistence against the predefined theshold values, alerts can generated using Hologram api as shown below.
try:
while True:
if sensor.get_sensor_data():
output = '{0:.2f} C,{1:.2f} hPa,{2:.2f} %RH'.format(
sensor.data.temperature,
sensor.data.pressure,
sensor.data.humidity)
if((sensor.data.gas_resistance) < Gas_resistance_threshold):
msg['Subject']='Alert for possible gas leak or smoke'
res_message = "High Gas Sensor Value"
+str(sensor.data.gas_resistance)
response_code = hologram.sendMessage(res_message)
Comments
Post a Comment