Pages: [1]   Go Down
Author Topic: MQ-3 alcohol sensor  (Read 1537 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dear experts
i have purchased alcohol sensor from the sparfun.com and according to data sheet i have connected 10k ohm resistor accross it and switche on for one whole day and night after that i try to write code and when alchol is not detected 200 value shows in the lcd i it should have shown value o how to solve this problem any idea ?
here is the code
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int ledPin = 13;
int sensorPin = A0;
int value = 0;

const int threshold = 350;

void setup()
{

Serial.begin(9600);
lcd.begin(16,2);

}

void loop()
{
int Value = analogRead(sensorPin);
value = analogRead(0);

if (Value > threshold)
{
    digitalWrite(ledPin, HIGH);
  }
  else {
    digitalWrite(ledPin,LOW);
  }

 
lcd.print("alcohollevel:");
lcd.println(value);
Serial.println(value,DEC);


if (Value > threshold)
{
    lcd.print("alert");
    Serial.print ("alert");
  }
  else {
    lcd.print("normal");
    Serial.print("normal");
   
  }
   
delay(1000);
lcd.clear();

}
« Last Edit: October 06, 2012, 10:27:05 am by santoshaxl » Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you wired it up correctly? You say i have connected 10k ohm resistor accross it but 10K resistor should not be connected across device but is to ground.

Your reading the pin twice
Code:
int Value = analogRead(sensorPin);
value = analogRead(0);
You don't need the second one. The device really needs calibrating using known alcohol concentrations.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if i remove second line value is displayed always zero what is the problem then .
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes 10k is connected to the ground and when the alcohol is present value varies from 200 to 1024 but when alcohol is not present shows value 200 my wiring is correct
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2557
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your confusing 'Value' with 'value'. C++ is case sensitive so these are totally separate variables.
Get rid of this line as it's not needed
Code:
int value = 0;

Correct case of these two lines so they say Value and not value
Code:
    lcd.println(value);
    Serial.println(value,DEC);
Logged


Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if i remove second line value is displayed always zero what is the problem then .

Value is not value

(edit: whops, it seems I was late smiley-razz )
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh yes that was my mistake i will check now smiley
Logged

Pages: [1]   Go Up
Jump to: