Forum Sensor.Community

Is there a way to get notification once sensor registers certain air polution

Is there a way to get an email or some other type of notification once the sensor registers certain pollution?
I installed a sensor outside my parents home. They live near the Klaipėda port which pollutes the air randomly, often they start to pollute in the evening. Parents have a HEPA air cleaner and it would be great if they knew when to turn it on.

Hello,

at the moment there is no such service on our side. Someone modified a lamp with an EPS8266 wifi module to request the actual data of a sensor and to change the color of the lamp accordingly to the air quality level.
Maybe this person is reading your question here …

1 Like

Build with an old NodeMCU 0.9 and RGB LED 8x8. Synchronisation via NTP with the official UTC Time in Paris (at least we still have this…).

It calls

https://data.sensor.community/airrohr/v1/sensor/{apiID}/

With a smaller light it could work on battery and be completely independent.

Can you help me to optimize the code ?

You could program a small webpage as well. It would show one color for example.

1 Like

Hi, I’m using the https://app.luftdaten.info/ for sending info email on various sensors after reaching certain threshold. Very convenient! Have a nice day.

1 Like

Many thanks, MichaelLazan! I’ve registered on app.luftdaten.info and will set up notifications for myself and my parents.

I’m not sure that app.luftdaten.info will work for newly registered sensors. This site isn’t maintained anymore. Source would be available but we don’t have someone who could work with this Ruby on Rails code.

Hello Balys,
The firmware has the possibility for a custom api.
This will do a htpp post of a json .
From there you have the data, so all ways are open.
MQTT is probably the way to go there.
A raspberry pi will do the job.

I use this for the sensor to post its data to a python program running flask and from there publish the data using MQTT.
I use this message in weewx for my weather website (http://weer.aslaets.be) and for Home Assistant.

Here is the python code that does the job:

#! /usr/bin/python3
# airrohr to mqtt for weewx and other 
# Version 1.0  27/07/2021



import time
# import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish
import json
from flask import Flask, request, jsonify

MQTT_SERVER = "mqtt.home"
MQTT_PORT = 1883
AIRROHRTOPIC = "airquality-front"
MQTT_CLIENT = "airrohr_data_1"
VALUEDICT_KEY = "sensordatavalues"
KEY_TABLE = {'SDS_P1' : 'pm10_0' ,
             'SDS_P2' : 'pm2_5' ,
             'BME280_temperature' : 'extraTemp2',
             'BME280_humidity' : 'extraHumid2',
             'signal' :'signal2'}

FLASK_PORT = 8080

app =  Flask(__name__)
app.config["DEBUG"] = False
# client = mqtt.Client(MQTT_CLIENT)

@app.route('/data/', methods=['POST'])
def handle_airrohr_data():
    ar_dict = json.loads(request.data)
#    print(ar_dict)
    out_dict = {}
    val_arr = ar_dict[VALUEDICT_KEY]
    ts = time.strftime('%Y-%m-%d %H:%M:%S')
    out_dict['time'] = ts
    for temp_dict in val_arr :
        if temp_dict['value_type'] in KEY_TABLE :
            out_dict[KEY_TABLE[temp_dict['value_type']]] = temp_dict['value']

# add timestamp
    pub_payload = json.dumps(out_dict)
    publish.single(AIRROHRTOPIC,payload=pub_payload,
            qos=0,retain=False,
            hostname=MQTT_SERVER,port=MQTT_PORT,client_id=MQTT_CLIENT)
    print("Published: ",pub_payload)
#construct an output dictionary from the airrohr dictionary

    return "DATA RECEIVED"

print("Airrohr to MQTT starting up")
app.run(host="0.0.0.0",port=FLASK_PORT)
1 Like