Needed in order for the following to work: See this thread on achieving an RFM69 Gateway & RFM69 nodes. See this thread on installing openHAB/MQTT on a local network-connected computer.
If we are sometimes near a node (like for a Flame Sensor or a MQ2 Gas/Smoke Sensor), we might desire an alarm sound if a risk condition is detected. Here's a wiring diagram of adding a piezo alarm to an IR_Flame_Sensor_digital node. This includes an optional push button on Arduino pin D8 to silence the alarm.
<< Forum members (free registration), click on pic for larger view.
As before, with activating only #define IR_FLAME_SENSOR_digital: A flame directly across from the board's LED-looking sensor will generate a Serial Monitor message & will send openHAB a 1 (one) on device 42. If no more flames are detected after the flameWatchMins, the Serial Monitor reports that & openHAB is sent a 0 (zero).
When #define ALARM is also activated, a flame detection will set off the alarm which will run until the optional button is pushed or no flame is detected for flameWatchMins or the alarmMins run out.
From here (if you have not already), download the latest choose_nodes sketch & follow the basic customization in that thread. That node sketch now includes code that can add a piezo alarm to some nodes.
In general with a MQ Gas/Smoke node, you will need to experiment with a good value for mqThreshhold. The MQ gas sensor needs some time between reads. So it is checked every 60 seconds during the periodic radio send. This may mean a slight delay before detecting gas/smoke or all clear. As before ... if the sensor value is at or above the mqThreshhold, the Serial Monitor reports that & openHAB is sent a 1 (one).
When #define ALARM is also activated, a value above mqThreshhold will set off the alarm which will run until the optional button is pushed or the value goes below mqThreshhold or the alarmMins run out.
So far the ALARM feature is only implemented for IR_Flame_Sensor_digital Node & MQ_Gas/Smoke Sensor Node.
For hints on adding an alarm to other sensors, search for #ifdef IR_Flame_Sensor_digital or #ifdef MQ_Gas AND #ifdef ALARM within those defined sections. Basically one has the code set alarmFlag to 1 (one) when a risk condition is found or set to 0 (zero) when the risk condition is sufficiently cleared.