Using picaxe with the Alcohol Gas Sensor?

westaust55

Moderator
Using picaxe with the Alcohol Gas Sensor

Can you explain your level of electronics knowledge. Might help people understand at what level to pitch their description.

As a broad starting poiint, the datasheet:
http://www.sparkfun.com/datasheets/Sensors/MQ-3.pdf
three-quarters of the way down page 1 has a diagram.

Recommend you use a DC and not AC supply for the heater in view of the circuit configuraiton

I could not see a range for Vout but it will not be greater than the supply voltage (5Vdc) so you can connect directly to an analogue input on a PICAXE and then just use the READADC command.

From my past experience with similar gas sensors in the past, it will take some time with the heater on before the sensor is ready for use. That is 0.75Watts at 5V => 150 mA onto heater for some time.

The datasheet in fact states:
"Pre heat time: Over 24 hours"


So seems you may need to leave it on more or less permanently.

Sensitivity is also temperature dependant so you may also need to consider adding a DS18B20 temperature sensor to your project as well.

Calibration is another topic all together.
 
Last edited:

Dippy

Moderator
Certainly the device would have to be preheated.
Not sure about time though - it claims an application as a breathalyser.
And that would, by implication, inlcude battery operated hand-held breathalysers (is that what it's for? hic!)
If the cops stopped me and asked me to wait 24 hours before a breath test I'd be very happy :) (Just kidding folks, don't drink and drive).

It's a typical and slightly old-fashioned sensor. Therefore cheap I guess?

Ambient temperature and humidity appear to affect it - but by how much I don't know (westy?).
The effect on an average day might be small, so it depends on the resolution/accuracy/repeatability you are hoping - therefore may need some experimenting with by the user.

Personally, I'd hunt around for a more 21st Century sensor.... even the 'recommended' breathalysers you can buy are ready to work in a few tens of seconds. Some old 80's sensors had a bridge arrnagment making them less suseptible to ambient.

As to the actual Output Voltage. I haven't got a clue. It will vary wrt RL. If it's too low for a reasonable resolution into your ADC then simply run it through an op-amp with a bit of gain.

And, as said, the calibration will be fun.
Enjoy.
 

sciguy77

Member
Hi,

I need a bit of help figuring out the wiring, which lead should go to the resistor and then to what pin in a picaxe microcontroller?

Also, and ideas as to how I could code this for a picaxe?

Thanks
 

westaust55

Moderator
what is the answer to the previously asked question in post 2:
Can you explain your level of electronics knowledge. Might help people understand at what level to pitch their description.

Did you look at the link in post 3?

It gives the circuit, the sensor pin arrangement, even photos on a breadboard.

The wire maked Vout must be wired to a PICAXE analogue input.
If you are not using a common/single power supply, then the bottom wire (0V at bottom of RL in diagram) must be connected to the 0V connection of the PICAXE circuit/power supply.

The code is simple:
READADC x, w0
where x is the input pin number you have connected to and w0 is the word variable into which the value corresponding to the sensor voltage is placed.

read about the READADC comamnd in the PICAXE Manual 2.


With no specific details on what you are trying to do no one can give you more information without guessing.
 

Dippy

Moderator
Without seeing one in front of me I can't check.

1. Determine which are the 2 wires for the heater coil.
This is cunning marked as "4" and "4" and then "H" and "H" - typical unambiguous drawing from a certain neck of the woods.
You can cofirm with a resistance check using a multimeter - what should the approx reistance read?

One of the heater pins goes to your 5V and the other to Ground (0V).
This device WILL be greedy on power, I would advice making this 'switchable' via relay or semiconductor switching or even a mechancical switch.

2. You should have 2 pins left over,
According to MY brief reading, connect either one of them to 5V and the other one is the OUTPUT to RL and then OUT to your PICAXE.

Look in the PICAXE MANUAL 1 to see the input pins of PICAXE which can be used as an ADC.
You DO NOT say which PICAXE you are using.
Let's guess and say it's an 18X.
LOOK in Manual 1 at the PINOUTS for the 18X.
See Pin 17 of the 18X.
"Input0 / ADC0 / Infrain "
This summaraises what this pin can do.

So then as Westy says above you can use READADC10 to give a good resolution value for the voltage at that pin.
Read MANUAL 2 (The BASIC language and other Info).
Once you have a value you can then compare it, within code.



Symbol MyGas = w1
Symbol Smelly = 200 ' Just a random value

MyStart:

ReadADC10 0, MyGas
If MGas > Smelly then
GoSub SwitchOnFan
Endif

Goto MyStart

Once you get used to programming you'll be able to see how to slicken it up, and how to do option, even how to calibrate it and even how to get rid of 'GOTO' completely.

Have fun. Be patient. Get some breadboard and a decent quality 5V supply.

Then we'll get onto the power supply AFTER you have got this going.

NOTE: To get good reliable ADC results, place a ceramic 100nF accross the V+/0V pins of your chosen PICAXE as close as physically possible to the actual chip pins (or 'legs' as they are quaintly called). Maybe also a few microfarads of electrolytic too in aparallel with the ceramic, say 10uF/10V for example.
This 'decoupling' at the PICAXE power supply pins can not be stressed enough if you want good ADC results.


There may be some more what-ifs and options to improve slickenitupisationability, maybe with pictures of breadboards (for which this is an ideal candidate btw) so I suspect this will run and run and confuse - well, that's my free 20 minutes worth, so good luck :)
 

sciguy77

Member
Hey, thanks for the great replies. I'm sorry I did not elaborate earlier, I'm very comfortable with a soldering iron and I understand the basics of how circuits work. However, I have a really hard time reading schematics.

Thanks!
 

sciguy77

Member
Quick update, my breathalyzer sensor just arrived in the mail. I think I'm fairly comfortable wiring it up (at least for now), but my BASIC coding skills are very limited. Could someone help me with getting input from the sensor?

Thanks!
 

Andrew Cowan

Senior Member
Connect the sensor to a PICAXE ADC pin. Are you able to do that?

Adapt Dippy's code so you get the system working as you need. Are you able to do that?

A
 

nbw

Senior Member
RTFM! Seriously, take your time to read the picaxe manuals, esp. #3 - the interfacing circuit. It will give you some good ideas.
 
Top