stefanbode / Sonoff-Tasmota

Provide ESP8266 based itead Sonoff with Web, MQTT and OTA firmware using Arduino IDE, enhanced with I2C options
GNU General Public License v3.0
126 stars 40 forks source link

Good MQ-2 Code #30

Closed whhsn closed 6 years ago

whhsn commented 6 years ago

Good code for MQ-2 sensor: http://www.mybotic.com.my/products/MQ-2-General-Combustable-Gas-Sensor-Module/308

stefanbode commented 6 years ago

For all of this MQ sensors, you do not need any code. There is a pure analog signal from 0..5V that cames out and must execute through an A/D chip. The ESP has one the A0. You can use this with a voltage divider before. Please take a look here in the Wiki. If you need more to connect use the ADS1115 board. This is natively supported by TASMOTO.

Finally: There is nothing to add :-)

stefanbode commented 6 years ago

Just saw the log and pow functions used in the calculations. We already had some discussions in the energy metering. To use this the math() library needs to be included and this will jeopardize the RAM. Sorry. This is too much for the ESP

whhsn commented 6 years ago

I am already using now it & the WeMos handles this beautifully :) Getting LPG, CO & Smoke readings not just a number!

stefanbode commented 6 years ago

Ok, I have added the whole sensor suite. Just now need to add some documentation how to define the sensors and do the calibration. the wiki need some update. Sensors are 5v and need a 165kOhm resistor before A0, if using the WEMOS D1 mini.

roblad commented 6 years ago

Hi,

There is similar code in my ino

https://github.com/stefanbode/Sonoff-Tasmota/blob/master/sonoff/xsns_94_MQ_SENSOR.ino

i did not observed any issues hangs during work because of pow() and log() functions. I have one issue in Sonoff 4ch pro. hangs when wifi disapeared, but I do not know if there is a MQ code problem, I have to test it , but I asked Stefan for some bin compilation because my platformIO is not updated yet to latest version.

but in config file there is some additional declaration needed

define USE_MQ_SENSOR

and for voltage measure

define USE_VOLTAGE

but both of them could not work simultaneously.

stefanbode commented 6 years ago

The bin is updated

stefanbode commented 6 years ago

How much flash has this device. If 512k, then we have the issue. The image is larger than it can be.

Sent from remote phone

Am 31.03.2018 um 08:39 schrieb roblad notifications@github.com<mailto:notifications@github.com>:

Hi,

I tryied but:

Sonoff 4CH Pro Module Sonoff Upload Failed

Magic byte is not 0xE9

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fstefanbode%2FSonoff-Tasmota%2Fissues%2F30%23issuecomment-377673915&data=02%7C01%7Cstbode%40ptc.com%7C40168e743af34bd5ac5308d596da80db%7Cb9921086ff774d0d828acb3381f678e2%7C0%7C0%7C636580787580597138&sdata=X5mv7n3G1mTfC3%2Fuu%2BmfiMUtBqM4yuSnKaQb5k7UcGY%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAPeUCsPBkEwn9FWdDwROCDRgVsVYVuw-ks5tjzKbgaJpZM4TATzK&data=02%7C01%7Cstbode%40ptc.com%7C40168e743af34bd5ac5308d596da80db%7Cb9921086ff774d0d828acb3381f678e2%7C0%7C0%7C636580787580597138&sdata=cvkyUou%2F58PxvymFdCLT1i6O5c0DP3zPfyQkkmH0KdQ%3D&reserved=0.

stefanbode commented 6 years ago

https://github.com/arendst/Sonoff-Tasmota/wiki/Sonoff-4CH-and-4CH-Pro

Maybe this helps

whhsn commented 6 years ago

@stefanbode - I am using the sensor without any resistor with the WeMos! I have no way to check if the collected ppm data is right or not - but it seems ok - increasing with smoke & lighter gas - this is good for my usage.

roblad commented 6 years ago

Hi,

I upgraded and work perfectly with my mq5 sensor no any hangs as in previous releases sonoff 4ch pro with gas sensor mq5 and DHT 23kb free memory

roblad commented 6 years ago

@whhsn

Hi,

You have to use resistor the voltage value you get when ppm is small is approx. below 3.3 V maximum voltage from sensor for CH4 concentration could be 4.5 V