Dear Community,
this is my first post, and first of all I want to say Hello to the other users of the forum.
I started to work with a arduino duemilanove which was a gift from a friend of mine.
My first steps were a knowledge collection for very basic electronic understanding.
What helps me is the simulation tool:
https://www.falstad.com/circuit/circuitjs.html
Here I simulated my circuit plan, the sensor was just exchanged with a lamp, with the same Power Consumption as the sensor. Maybe not 100% accurate, but it worked fine to check the parameters and If my circuit with work.
I connected the 5V connector from arduino with the 10 Ohm resistor, and ground connector with the 25 Ohm resistor. Then I connected the 25 Ohm resistor with ground connector from the sensor, and the 10 ohm resistor with the VCC connector of the sensor.
Better would be 33 Ohm resistor in line, but I don't have enough 1 Ohm Resistors here, in the datasheet of the sensor, it is written, 33 Ohm, at 5V, which is simple when you know the 750mW power consumption and the 5V operating voltage. It is 0,75W/ 5V=0,15A. The resistors calculation is just 5V / 0,15A = 33,33Ohm.
My sensor is the MH MQ-3, it has 4 connector, one digital out, one analog out, ground and VCC.
First I was a bit frustrated, I bought the sensor in a box of many sensors, at amazon, and the dealer didn't submitted the datasheets, but hey they were cheap
So I was lucky and found them via google.
The other MH Sensor datasheets you can find here:
MQ-3 Alcohol Sensor Module Pinout, Datasheet & Other Gas Sensors (components101.com)
I'm also new to programming, I had a small course 10 years ago at university, but when you don't code for a couple of years, you will forget.
So my code is very basic, but it works fine.
Resistance value of MQ-3 is difference to various kinds and various concentration gases. So,When using
this components, sensitivity adjustment is very necessary. we recommend that you calibrate the detector for
0.4mg/L ( approximately 200ppm ) of Alcohol concentration in air and use value of Load resistancethat( RL) about
200 KΩ(100KΩ to 470 KΩ)
So what I did here, I calculated Promille=(0,4/200) * value of the analog output *2.
Die Umrechnung mg/l in Promille: Einfache Rechnung
Um von den angegeben mg/l auf den ‰-Wert zu gelangen, gilt ein gesetzlich vorgeschriebener Umrechnungsfaktor von 2,00. Demnach muss der mg/l-Wert mit zwei multipliziert werden, so entsprechen zum Beispiel 0,4 mg/l Atemalkoholgehalt 0,8 ‰ Blutalkoholgehalt.
My code:
/* MQ-3 Alcohol Sensor Circuit with Arduino */
int AnalogPin=0;//the AOUT pin of the alcohol sensor goes into analog pin A0 of the arduino
int value1 = 0;
int value2 = 0;
float promille=0;
void setup() {
Serial.begin(115200);//sets the baud rate
pinMode(AnalogPin, INPUT);//sets the pin as an input to the arduino
delay(14400000); // this it the pre heat time, maybe not enough, I make a check today
}
void loop()
{
value1= analogRead(AnalogPin);//reads the analaog value from the alcohol sensor's AOUT pin I guess it is Parts per Million
value2=value1 - 98; // here I made a small work around, this sensor has a very long pre heat time, when it is not heated to working temperature, it will show values too high even when there is no alcohol, thats why I removed the amount which was over 0, when no alcohol was next to it
// limit= digitalRead(DOUTpin);//reads the digital value from the alcohol sensor's DOUT pin
Serial.print("Alcohol value: ");
Serial.println(value2);//prints the alcohol value
promille = (0.4/200)*value2*2;
Serial.print("Promillewert: ");
Serial.println(promille,3);
//Serial.print("Limit: ");
//Serial.print(limit);//prints the limit reached as either LOW or HIGH (above or underneath)
delay(100) ;
}
Next I will try to improve my code, with a array for the promille values for 4 or 5 seconds, and I want to calculate the middel value of the 40 or 50 values. The idea behind the values are quite a bit unstable from one value to the other one.
I hope this helps you, some people maybe don't need all the infos here, but I thought I also read a lot in the forum, and profited from it, so I also wanted to do a post about my project.