|
Post by papa on Mar 24, 2019 13:41:52 GMT
MQ2 Gas/Smoke Sensor Node, Introduction
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.
Parts: I used this MQ-2 Smoke Hydrogen Butane LPG Methane Sensor with analog output. I also used 3 color-coded male to female dupont cables to connect the sensor to the Buono Uno Arduino compatible. The wiring diagram below displays other parts needed.
This source gives an introduction to the MQ sensors. Besides smoke, this sensor is supposed to sense flammable and combustible gasses. I assume we need to place the sensors where they would earliest detect what we are watching for, like ceiling placement for smoke.
Readings from the MQ2 sensor are not valid until a few minutes ( 2 or 3 ??) after it is powered & its heater warms up. When first powered in clear air, my sensor output 225, 113, 79, 67, 61, 57, 56, 53, 52 & eventually mostly low 40's. Then light smoke raised the detected value to the 70's. Close breath raised it to 100.
MQ2 Gas/Smoke Sensor Node, Wiring
|
|
|
Post by papa on Mar 25, 2019 13:23:29 GMT
MQ2 Gas/Smoke Sensor Node, Wiring << Forum members (free registration), click on pic for larger view.
Next, MQ2 Gas/Smoke Sensor Node, Programming
|
|
|
Post by papa on Mar 26, 2019 14:23:35 GMT
MQ2 Gas/Smoke Sensor Node, ProgrammingFrom here, download the latest choose_nodes sketch & follow the basic customization in that thread. That node sketch now includes an MQ_Gas option which will send a change of gas/smoke status every 60 seconds. (I tweaked code Joshua provided earlier.)
Near the sketch's end, see version updates & credits. See the links in this post for documentation on several kinds of nodes you can program with this sketch. In addition to the above basic customization ... // #define MQ_Gas << UNcomment this line (delete //) #define NODEID 05 << change 05 to a unique number in your RFM69 network (For this node, I suggest you use NODEID 70 as I will below.) Search for the sketch's first "#ifdef MQ_Gas" Then a few lines later see ... #define mqThreshhold 100 // papa: reading above this = gas or smoke detected bool gasFlag = 0 ; // papa: below mqThreshhold = 0, above mqThreshhold = 1 Via experimentation, adjust mqThreshhold for your purposes. Next, Serial Monitor Results
|
|
|
Post by papa on Mar 27, 2019 13:58:39 GMT
MQ2 Gas/Smoke Sensor Node, Serial Monitor ResultsBy this time, you should have at least an RFM69 Gateway (see this post above) & an Gas/Smoke Node 70 programmed for NetworkOne. When the Gateway is local network-connected & running, the node was programmed with DEBUG, the node is USB-connected to the Arduino IDE computer, & the Arduino IDE Serial Monitor is opened: immediately & then every 60 seconds, you should see four device values: 1) device 02 (Radio Signal Strength), 2) dev 04 (node voltage), 3) dev 09 (how many times the node tried to resend data before the gateway acknowledged receiving), 4) dev 70 (Gas/Smoke Risk value). In addition on the Serial Monitor, you will see if the Gas/Smoke value is below or above the threshold set for concern. Next, openHAB configuration
|
|
|
Post by papa on Mar 28, 2019 18:58:13 GMT
MQ2 Gas/Smoke Sensor Node, openHAB configuration
PaperUI\configuration\Things Add Thing (click + in blue disc) click MQTT Binding Add Manually Generic MQTT Thing Node70 Location (arbitrary physical location) BaseFR MQTT Broker - mqtt:systemBroker:embedded-mqtt-broker save (click check mark in blue disc)
PaperUI\Configuration\Things\Node70 Add channels (click + in blue disc)
Type: Text Channel ID: Node70Channel02 Label: Node70_RSSI State topic home/rfm_gw/nb/node70/dev02
Type: Number Channel ID: Node70Channel04 Label: Node70_Volts State topic home/rfm_gw/nb/node70/dev04
Type: Text Channel ID: Node70Channel70 Label: Node70_Gas_Flag State topic home/rfm_gw/nb/node70/dev70 incoming value transform: MAP:onoff.map
Next, OpenHAB Configuration, continued
|
|
|
Post by papa on Mar 29, 2019 13:38:24 GMT
OpenHAB Configuration, continued
In openHAB's \conf\transform folder, add onoff.map file with the contents: 0=OFF 1=ON
In openHAB's \conf\items folder, add to an .items file, perhaps a new Node70.items
String Node70RSSI "Node70rssi (db)[%s]" <network> (Nodes) { channel="mqtt:embedded-mqtt-broker:topic:mything:Node70Channel02" }
Number Node70Vlts "Node70Volts [%.2f Vdd]" <battery> (Nodes) { channel="mqtt:embedded-mqtt-broker:topic:mything:Node70Channel04" }
String Gas70 "Gas70 [Gas/Smoke Risk %s]" <siren> { channel="mqtt:embedded-mqtt-broker:topic:mything:Node70Channel70" }
Important: Link the above items to the matching channels in the previous post (you may need to stop & restart openHAB).
In openHAB's \conf\sitemaps folder. add to a .sitemap file: Text item=Gas70
|
|