MQ2 Smoke Sensor

250 views
Skip to first unread message

Marius Vosylius

unread,
Mar 26, 2014, 11:16:38 AM3/26/14
to ioio-...@googlegroups.com
I'm looking to use MQ-2 Smoke Sensor with my IOIO-OTG Board.

First Question: Is it possible to do it?
Second Question: How to Do it, any example code etc?

I found Michaels page http://mitchtech.net/android-ioio-breathalyzer/ with MQ-5 (Alcohol Sensor Example), is MQ-2 would be similar?


Sensor Image Bellow:

Thanks in Advance.





Ytai Ben-Tsvi

unread,
Mar 26, 2014, 11:59:28 AM3/26/14
to ioio-...@googlegroups.com
They seem to be very similar. The value of the load resistor should probably be different though (I'd use 1Mohm) and I would connect a capacitor in parallel to the load resistor (I'd use 0.1uF or so).
The provided code doesn't seem to attempt to map the measured voltage to the physical quantity the sensor is measuring, but once you get there I can help you with that. First, just verify that you're getting the measured voltage to change in reaction to the gas presence.


--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Marius Vosylius

unread,
Apr 1, 2014, 4:37:52 PM4/1/14
to ioio-...@googlegroups.com
Dear Ytai, I have followed these steps and able to output V out. Heres a picture of my code below:

My V Outpout is: 2.8 - 3.0 V 
Reading Output is: 0.87 - 1.

Please advise me what else do I need to do to get Gas MQ2 Reading. Thanks.

Ytai Ben-Tsvi

unread,
Apr 1, 2014, 8:25:10 PM4/1/14
to ioio-...@googlegroups.com
Are you using the bare sensor or a breakout board that has a few more components on it? If that latter, please send a product page link or, even better, a schematic.


--

Marius Vosylius

unread,
Apr 2, 2014, 4:35:24 AM4/2/14
to ioio-...@googlegroups.com
Ytai I'm using Breakout Board, not a bare Sensor. 

GND - BreadBoard-GND + 1 (10k Ohm)
VCC - BreadBoard-VCC
AOUT - IOIO (Pin40)

Ytai Ben-Tsvi

unread,
Apr 2, 2014, 12:04:07 PM4/2/14
to ioio-...@googlegroups.com
There's no schematic there, so on this explanation I'll assume that you have the bare sensor in hand, which is probably not the case.

Connect one of {A,B} pins and one of the H pins to IOIO 5V.
Connect the other H pin to IOIO GND.
Connect the other {A,B} pin through a 4.7kOhm resistor to IOIO GND.
Also connect that same pin to an analog input.

The sensor changes its resistance depending on several factors, gas presence being one of them. The voltage you'll be reading on the analog pin, assuming the sensor's resistance is R will be:

V = 5 * 4700 / (4700 + R)

You can solve for R, given a measured voltage. Now, you can translate R to concentration of gas according to the charts in the datasheet. Note that you'll need to know, or assume, the humidity and temperature.

The value 4.7k has been specifically chosen to guarantee the voltage on the analog pin does not exceed 3.3V. Do not use a higher value resistor as you may damage the IOIO.

Marius Vosylius

unread,
Apr 2, 2014, 12:24:48 PM4/2/14
to ioio-...@googlegroups.com
Its a bit confusing Ytai, can you please have a look at picture attached and tell me if Im doing it ok:

Black GND - IOIO-GND
AOUT - IOIO Analog Pin
VCC - IOIO 5V.

What else do I need to connect.

I don't have smaller resistor than 10k Ohm, I have ordered assorted kit today.

What do I need to change in my Java Code?

V = 5 * 4700 / (4700 + R)

Can you please throw example that would suit to my code.

 

Ytai Ben-Tsvi

unread,
Apr 2, 2014, 8:05:43 PM4/2/14
to ioio-...@googlegroups.com
I can't answer without knowing exactly what circuit is on the breakout board. Let me know if you can find a schematic.
Also, as I said, do not use a higher value resistor, or you might damage the IOIO by exposing the analog pin to an over-voltage. Connecting two 10kOhm in parallel would give you 5k, which should be OK. Change 4700 to 5000 in the code if you do that.



--

Marius Vosylius

unread,
Apr 3, 2014, 3:30:25 AM4/3/14
to ioio-...@googlegroups.com
Dear Ytai, Ill try to get MQ2 schematic, if no I will draw it myself. Thank you.

Marius Vosylius

unread,
Apr 3, 2014, 12:44:46 PM4/3/14
to ioio-...@googlegroups.com
I found 2 Sources there information can be useful:


Hopefully this gives more information and schematic explanation about this sensor. 
If not please let me know and I will try to draw schematic on my MQ-2 Sensor.

Regards,
Marius

Ytai Ben-Tsvi

unread,
Apr 3, 2014, 8:29:14 PM4/3/14
to ioio-...@googlegroups.com
This one looks more like it, but no schematic:

However, they do mention that the load resistance is variable, so it is possible that the trimmer on the board is what you need. Measure the resistance between AOUT and GND and see if it changes when you turn the pot. If it does - good! Just set it to around 5K and change the code according to the actual value.


--

Marius Vosylius

unread,
Apr 3, 2014, 8:39:00 PM4/3/14
to ioio-...@googlegroups.com

Can you tell me what is trimmer?

You received this message because you are subscribed to a topic in the Google Groups "ioio-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ioio-users/hwQrvPabwqc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ioio-users+...@googlegroups.com.

Ytai Ben-Tsvi

unread,
Apr 3, 2014, 8:43:43 PM4/3/14
to ioio-...@googlegroups.com
It is the part that has a little screw on your breakout board.

Marius Vosylius

unread,
Apr 3, 2014, 9:03:49 PM4/3/14
to ioio-...@googlegroups.com

Thank you. I'll let you know this evening.

Marius Vosylius

unread,
Apr 4, 2014, 10:34:17 AM4/4/14
to ioio-...@googlegroups.com
Ytai, I have measured the resistance between AOUT and GND. Please see Images bellow of my output, hopefully I did measure it right if no please correct me.


Ytai Ben-Tsvi

unread,
Apr 4, 2014, 2:35:16 PM4/4/14
to ioio-...@googlegroups.com

Negative resistance? Cool!
Please disconnect everything and repeat the test.

Marius Vosylius

unread,
Apr 4, 2014, 3:01:20 PM4/4/14
to ioio-...@googlegroups.com
-540 & - 538

Marius Vosylius

unread,
Apr 4, 2014, 3:19:24 PM4/4/14
to ioio-...@googlegroups.com
Without 10k Ohm Resistor:
250 +

Ytai Ben-Tsvi

unread,
Apr 4, 2014, 6:26:53 PM4/4/14
to ioio-...@googlegroups.com

I have no idea how to interpret this result... Looks like you going to use the continuity meter to reverse engineer the schematic of this board. We only care about how the sensor is wired to aout and any additional resistors in parallel.

Marius Vosylius

unread,
Apr 5, 2014, 2:19:02 AM4/5/14
to ioio-...@googlegroups.com

Does that mean that there's something wrong with sensor or ioio?

You received this message because you are subscribed to a topic in the Google Groups "ioio-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ioio-users/hwQrvPabwqc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ioio-users+...@googlegroups.com.

Ytai Ben-Tsvi

unread,
Apr 5, 2014, 2:36:44 AM4/5/14
to ioio-...@googlegroups.com

No. That just means we don't understand the sensor board.

Marius Vosylius

unread,
Apr 5, 2014, 3:19:04 AM4/5/14
to ioio-...@googlegroups.com

Maybe I need to get another sensor?

Ytai Ben-Tsvi

unread,
Apr 6, 2014, 9:34:51 PM4/6/14
to ioio-...@googlegroups.com
Suit yourself. I think this one is probably fine, you only need to figure out how it's wired. Otherwise, you can possible desolder the sensor from the breakout and use it directly.

Marius Vosylius

unread,
Apr 7, 2014, 1:27:32 PM4/7/14
to ioio-...@googlegroups.com
Ytai, I was able to use one of the Grove MQ2 Sensors below, but a thing is that its only works without a resistor. Is this is ok?

Ytai Ben-Tsvi

unread,
Apr 7, 2014, 1:40:58 PM4/7/14
to ioio-...@googlegroups.com
You should measure resistance between out and GND (when the sensor is not connected to anything) and turn the pot until you get about 5kOhm. Then you can do everything we discussed previously in order to derive the actual gas concentration.


On Mon, Apr 7, 2014 at 10:27 AM, Marius Vosylius <marius....@gmail.com> wrote:
Ytai, I was able to use one of the Grove MQ2 Sensors below, but a thing is that its only works without a resistor. Is this is ok?

--

Marius Vosylius

unread,
Apr 7, 2014, 2:05:05 PM4/7/14
to ioio-...@googlegroups.com

Thank you!

You received this message because you are subscribed to a topic in the Google Groups "ioio-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ioio-users/hwQrvPabwqc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ioio-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages