mr513 hotwire alcohol gas sniffer interface to arduino

hey guys anyone got an idea how to interface this to the arduino? theres a few tutorials for the mq3 but this sensor is inaccurate. would really appreciate the help.

You would get a better response with a data sheet I think this is the sensor; http://www.cooking-hacks.com/skin/frontend/default/cooking/pdf/MR513.pdf

I'd connect one of the power line to GND, and another to 3.3V via 3 Ohm resistor. Than connect two outputs lines to analog inputs, difference returned by two analogRead from each port would give concentration

Magician: I'd connect one of the power line to GND, and another to 3.3V via 3 Ohm resistor. Than connect two outputs lines to analog inputs, difference returned by two analogRead from each port would give concentration

hey magician thanks for the response. The datasheet hasnt got the power lines marked so not sure which pins are for power and which pins are the output pins. With the mq3 we only needed to connect one of the output pins to the arduino input. would the theory be the same with this sensor?

thanks for your response.

Radman posts a link to datasheet, if it correct sensor you are using(?), than there are marks D and C. Or you can use multimeter to find out the pins. I'm not familiar with mq3 sensor, but well known advantage of bridge configuration is error cancellation: - power line - noise / ripple / instability ; - temperature / atmosphere pressure fluctuation; - aging of sensor; It doesn't worth to use one signal line for measurements, as you can't compensate all this factors. You can use OPA if there is not enough analog pin on your arduino.

thanks for that magician. yes its the correct datasheet. after reading up on the wheatstone bridge i now know that i need to connect to nodes to power(excite) and two to analogue input. what i need to know is do i then subtract the differnce in values of the two pins to get a accurate read out, with a sensor such as this do i need an amplifier for the read seeing asthough the max read of the analogue pin is 1024?

also with the arduino 3.3v pin the mA throughput is only 50mA this sensor needs atleast 100mA to run. Each i/o pin on the arduino is 40mA, could i just turn 3 pins to output and power the sensor of these 3 pins(total 120mA)?

appreciate the help

do i then subtract the differnce in values of the two pins to get a accurate read out?

Yes, it's the main idea of bridge, you process differential signal, something like: int input1, input2, results; input1 = analogRead (pinA); input1 = analogRead (pinA);// two times just in case input2 = analogRead (pinB); input2 = analogRead (pinB); results = abs ( input1 - input2 );// abs - to get rid of sign if you swap power lines

do i need an amplifier for the read seeing asthough the max read of the analogue pin is 1024?

It depends. Output of the sensor 120 mV, so basically it would works w/o amplifier, the same time sensitivity would be better if you add one later on.

arduino 3.3v pin the mA throughput is only 50mA this sensor needs atleast 100mA to run.

It's not quite accurate, and again it depends how you power up your board. On-board 3.3V chip could provides 150 mA.

Each i/o pin on the arduino is 40mA, could i just turn 3 pins to output and power the sensor of these 3 pins(total 120mA)

No. In first you don't need it, in second why not to use +5V rail (with right serial resistor to drop voltage to 3V)? Only if your device is portable, and you trying to save power turning off heater, and don't have a transistor around, you can do it grouping 5 (no more than 20 mA per pin) ports/outputs together.

hey magician thanks for that great help! the c and d pins are divided up in pairs. what i think is the correct wiring is connecting one d pin to power and the other d pin to gnd. then i connect two c pins to analogue input. i couldnt get a 3ohm resistor so i got a 20ohm resistor instead and hooked up the 5v rail to the resister then to the d pin. Is the the correct setting?? im getting random numbers when viewing the serial data. also is the output in parts per million?

thanks heaps

connecting one d pin to power and the other d pin to gnd. then i connect two c pins to analogue input

No, according to schematic , c and d have to be connected in series, and this "middle-point" goes to input. Two sides for power and ground. How long are wires to sensor? I should ask this earlier, because if sensor and microcontroler stay close ( ~ 1m), you can omit voltage divider and make measurements with only one input.

cables to the sensor are 5cm long. im also seeing something strange with my arduino uno. im reading the analogue ports with nothing connected and im getting a variable reading from 0-300. shouldnt it be a constant 0 with nothing connected to the input port. code below

int sensePin = 2; // sets pin 2 as input for the sensor int val = 0; // variable to store the value coming from the sensor

void setup() { Serial.begin(9600); // use the serial port to send the values back to the computer }

void loop() { val = 0; val = analogRead(sensePin); // read the value from the sensor

Serial.println(val); // print the value to the serial port delay(1000); // wait a bit }

It's fine, arduino is too sensitive , so if nothing connected to port , it's picking up RF interference from the air.

Magician: It's fine, arduino is too sensitive , so if nothing connected to port , it's picking up RF interference from the air.

yeh cheers, i dont suppose there is a way of cancelling this noise out?

still having no luck with the sensor connecting to arduino.... i have paired two pins from either side(c&d). c -> ground, d -> vcc & c->analogue in d-> analogue in changed combinations exposing to alcahol not getting a reading... hmm.. vcc is connected via a 20ohm resistor to 5v..

cancelling that noise would be a great start..

c -> ground, d -> vcc & c->analogue in d-> analogue in

Should be : Vcc - > R 20 Ohm -> C1 ------ C2 -> D1 ------ D2 -> Gnd. ^ | Analog Input Don't worry about noise, it's disappear when you connect input to something, to sensor in your case.

Magician:

c → ground, d → vcc & c->analogue in d-> analogue in

Should be : Vcc - > R 20 Ohm → C1 ------ C2 → D1 ------ D2 → Gnd.
^
|
Analog Input
Don’t worry about noise, it’s disappear when you connect input to something, to sensor in your case.

ok i think i finally got something. hooked up vcc to the 20ohm which i connected to c1. connected c2 to d1 then connected to analog input. d2 to ground. when i read the A0 pin im getting a standard number of 100(is this interference??) when i blow on the sensor with a mouth full of alcohol the reading increments by 1. the harder i blow the higher it goes. i managed to get the reading to goto a max of 120. i know with other sensors such as the mq3 the analog reading goes to around 1023(max ADC). Does this sound right or do you thing the resistor im using weak?

The simple troubleshooting 'd be measurements of current from power supply line. Data spec says 100 mA. Resistor is about right to drop 2V, as sensor require only 3V. Output (no alcohol) I 'd expect to be ~ 1.5V or 300 in arduino "ticks". You can set other analog input as voltage control point between c1 and resistor, and confirm is there 3V (600 ticks)? Or use a voltmeter. Output (with alcohol) should differ from stand by state around 120 mV, or 24 ticks. Math is simple : V = 1024 x 0.120 / 5 You can program it in arduino using floats and report back ppm value via look up table from data sheet. No way you can get +5 at the output, so your 120 - 100 = 20 ticks difference is all you can get w/o amplification. What is wrong, it 100 steady reading instead of 300.

Magician: The simple troubleshooting 'd be measurements of current from power supply line. Data spec says 100 mA. Resistor is about right to drop 2V, as sensor require only 3V. Output (no alcohol) I 'd expect to be ~ 1.5V or 300 in arduino "ticks". You can set other analog input as voltage control point between c1 and resistor, and confirm is there 3V (600 ticks)? Or use a voltmeter. Output (with alcohol) should differ from stand by state around 120 mV, or 24 ticks. Math is simple : V = 1024 x 0.120 / 5 You can program it in arduino using floats and report back ppm value via look up table from data sheet. No way you can get +5 at the output, so your 120 - 100 = 20 ticks difference is all you can get w/o amplification. What is wrong, it 100 steady reading instead of 300.

voltage confirmed by testing analogue input between c1 and resistor. reading 624. so the max reading i can get is the standby voltage + 24. now the standby voltage is reading 114 on the analogue pin so the max reading would be 138. hmm seems to be a rather limited testing range. with this tight range i would expect a maximum bac reading of around 0.2 ...?

update the sensor is changing value just when blowing on it without consuming any alcohol or no alcohol present in the mouth.

you have been a great help magician!

i too am having trouble with connecting this sensor to the arduino.

when i connect one c leg to vcc(with resistor) and the other c to a d leg which then goes to analogue input i get 1023 as the reading. this is constant reading. if i connect any of the c pins to vcc the other c pin goes high does this mean it needs to be grounded? i have tried multiple combinations with little success

update the sensor is changing value just when blowing on it without consuming any alcohol or no alcohol present in the mouth.

Who says it shouldn't ? Sensor will react on air flow, so you breathe on it gently. Plus there is a response time 20 sec. Also, I think sensor reading affected by presents other gases in the air :)