Arduino 101: Alcohol sensor circuit using MQ-3 module

in #utopian-io8 years ago (edited)

What Will I Learn?

  • You will learn how to use an alcohol sensor with the arduino uno.
  • You will learn the working principle of how alcohol sensor works.
  • You will learn how digital input and output works and be able to program the arduino board.

Requirements

Hardware

  • Arduino Uno


    image.png

Image source

  • Alcohol sensor MQ-3


    image.png

Image source

  • LED


    image.png

Image source

  • Jumper wires


    image.png

Image source

  • Breadboard


    image.png

Image source

  • Computer


    image.png

Image source

  • USB type A to B cable


    image.png

Software

  • Arduino Software / Arduino IDE

Knowledge

  • Basic electronics and programming knowledge

Difficulty

  • Basic

Project description

In this project we will be using an MQ-3 alcohol sensor to measure the amount of alcohol in one's breath. This sensor is very sensitive to ethanol, which is a type of alcohol that is found in every alcoholic beverages like beer, liquor and wine. This circuit can be used as a breath analyzer to check the person's alcohol level.

Component description

Arduino Uno - a board that is produced by arduino and it is the most regularly utilized by specialist/hobbyist due to its robust and strong outline. It is packed with a microcontroller board that depends on ATMega328P with 14 advanced I/O pins (6 are PWM outputs), 6 analog inputs, 16 Mhz quartz crystal, a power jack, a USB port, an ICSP header and a reset button.

MQ-3 alcohol sensor - Just like a common breath analyzer, this sensor is suitable in detecting alcohol concentration present in the breath. This device has high sensitivity and fast response time, so it can take the measurements as fast as possible.

Tutorial Contents

Alcohol sensor circuit using MQ-3 module

Step 1: Gather the parts

  • You can buy the components at your local electronics shop or order it up online.

image.png

Step 2: Construct the circuit

Connect the sources

  • Connect the 5V pin of the arduino uno board into the top/bottom row of the breadboard (the connections here are horizontally connected).
  • Connect the GND pin of the arduino uno board into the top/bottom row of the breadboard.
  • Note: Make sure not to short them out to avoid damage.

image.png

Connect the sensor

  • Connect the +5 volts pin of the alcohol sensor to the positive terminal in the breadboard.
  • Connect the GND pin of the alcohol sensor to the negative terminal in the breadboard.
  • Connect the analog output pin of the alcohol sensor to analog pin number 0 in the arduino board.
  • Connect the digital output pin of the alcohol sensor to pin number 8 of the arduino uno board.

image.png

Connect the LED

  • Connect the anode(+) of the LED to pin number 13 of the arduino.
  • Connect the cathode(-) of the LED to the GND pin of the arduino.

image.png

Step 3: Programming

  • Connect the arduino board to the computer by using the USB type a to b cable.
    image.png
    Image source

  • Open the arduino IDE and then head to Tools > Board : > then select Arduino/Genuino Uno.
    image.png

  • Copy the codes below and paste it into your sketch in arduino IDE.

const int Apin=0;   //sets the Analog pin of the alcohol sensor into analog pin A0 of the arduino
const int Dpin=8;   //sets the Digital pin of the alcohol sensor into digital pin D8 of the arduino
const int ledPin=13;//sets the anode of the LED to digital pin D13 of the arduino
int limit;
int value;
void setup() {
pinMode(Dpin, INPUT);    //sets the pin as an input to the arduino
pinMode(ledPin, OUTPUT); //sets the pin as an output of the arduino
}
void loop()
{
value= analogRead(Apin);//reads the analaog value from the alcohol sensor's AOUT pin
limit= digitalRead(Dpin);//reads the digital value from the alcohol sensor's DOUT pin
if (limit == HIGH){
digitalWrite(ledPin, HIGH);//if limit has been reached, LED turns on as status indicator
}
else{
digitalWrite(ledPin, LOW);//if threshold not reached, LED remains off
}
}

What this code does is very simple, first it declares the pins of the alcohol sensor and LED as cons int meaning it will be a read-only variable and cannot be changed. Then it sets up the Dpin as the input and the ledpin as the output. This will read the data from the alcohol sensor and the LED will indicate the output. In the loop setup, it will read the Apin of the alcohol sensor in integer values, it would also read the data from Dpin and store those values into the integer limit. The numeric values will be ranging from 0 (no alcohol) - 1023 (maximum level of alcohol), if the alcohol intake detected is under the threshold level, the value would be a LOW but If the alcohol intake is detected above the threshold, the value would be a HIGH thus turning ON the LED.

  • After typing the code into your arduino IDE, click the Verify button to save it and start compiling the sketch.

image.png

  • Once there is no errors found in the code, click Upload to install the program into the arduino uno board.

image.png

Step 4: Testing

  • Once the installation has been completed, remove the arduino uno from your computer and connect some battery packs to it to activate the circuitry.
  • Now test it to someone who just had a booze, let him breath to the sensor. If he's alcohol intake is high enough this should light up the LED but if not, the LED will stay OFF.
  • If none is working, redo the previous steps carefully and make sure to follow it.

Curriculum

Here are some of my arduino tutorials that you may also like:



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thank you😁

Hey @ted7 I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.13
TRX 0.34
JST 0.036
BTC 108529.70
ETH 4405.54
USDT 1.00
SBD 0.82