Alcohol detectors are commonly required by the law enforcement. The police need to catch and check people who drive after taking alcohol. Driving after taking alcohol can result in serious accidents. People who drive after consuming alcohol not only risk their own life but also of others. That is why police need to remain alerted and verify any person who they found suspicious of driving after drinking. For the verification, they use an instrument called alcohol detector. This project is aimed at building a similar device which will detect the consumption of alcohol by a suspect and display a digital reading indicating the level of alcoholic consumption. The device will also have a dial which will rotate and an LED indicator which glows to indicate a dangerous level of consumption by a suspect.
The MQ-3 sensor is used in the project to detect alcohol level. The sensor detects the alcohol consumption by the smell of the breath. The sensor is an analog as well as a digital sensor which on its analog pin outputs the analog voltage proportional to the alcohol level. The project is built on Arduino Pro Mini as the device is designed to be a handheld device. Apart from the MQ-3 sensor, a servo motor and an LED is also interfaced to the controller board to move the dial and indicate a dangerous level of consumption through LED indication. The reading taken by the sensor is displayed on a 16X2 character LCD.
The Arduino sketch manages to take the reading from the MQ-3 sensor, digitize and display reading, compare reading with a threshold level and operate LED as well as Servo to indicate a dangerous level of consumption. The Arduino code is written on Arduino IDE and burnt to the Pro Mini using the same.
The circuit is based on Arduino Pro Mini. The MQ-3 sensor, LCD display, Servo motor and LED are connected to the Arduino board. The circuit connections are as follow -
Power Supply - The circuit needs a 5V regulated DC for its operation. An 18V battery can be used as the primary source of power. The supply from the battery can be regulated to 5V using 7805 voltage regulator IC. The pin 1 of the voltage regulator IC should be connected to the anode of the battery and pin 2 of it should be connected to the ground. The voltage output must be drawn from pin 3 of the 7805 IC.
MQ-3 Sensor - MQ-3 is an analog as well as a digital sensor which detects alcohol consumption by the smell of the breath. The sensor has four pins - Analog Out, Digital Output, VCC, and Ground. The VCC and ground are connected to the common VCC and Ground. The digital output pin is not used therefore is kept not connected. The output of the sensor is drawn from the analog output pin which is connected to the pin A0 of the Arduino board.
16X2 LCD - The 16X2 LCD display is connected to the Arduino board by connecting its data pins to pins 4 to 7 of the Arduino board. The RS and E pins of the LCD are connected to pins 2 and 3 of the Arduino board respectively. The RW pin of the LCD is grounded.
The standard open-source library for interfacing LCD with Arduino UNO is used in the project. The library works as expected and needs no changes or modifications.
Servo Motor - The servo motor is used to rotate a dial indicating a dangerous level of alcoholic consumption. The servo motor has three terminals - VCC, Ground, and Control. The VCC and Ground are connected to common VCC and Ground respectively. The control terminal of the motor is connected to pin 10 of the Arduino board. A pulse width modulated signal need to be passed to the control terminal of the servo in order to rotate it between angles 0 and 180 degrees.
LED - An LED is connected to pin 12 of the Arduino board with its anode connected to the pin and cathode to the ground. The LED starts glowing as the level of alcohol is detected beyond legalized limit.
How the circuit works -Arduino based Alcohol Detector Circuit Displaying Alcohol Level
Once the device is powered on by attaching a battery, the Arduino sketch starts running. It loads the required Arduino libraries and initializes LCD display. Some initial messages are displayed on the LCD. The Arduino starts detecting analog voltage from the sensor and converts it to a digital value using inbuilt Analog to Digital convertor. The reading is displayed on the LCD screen which by default remains to zero.
When police catch a suspect and test his breath, the MQ-3 sensor outputs a higher voltage at its analog output pin. The voltage is converted to a digital value using inbuilt Analog to Digital convertor and displayed on the LCD screen. The in-built ADC channel is 10-bit long and can have digitized reading up to 1000. After calibration, the level of alcohol beyond the legal limit is found to result in digitized reading beyond 500. Therefore, the digitized reading of the sensor is compared with 500 and if it is found beyond 500, the servo motor is rotated by an angle of 100 which results in rotation of the dial by the same angle. The standard Arduino library function is used to implement the rotation of servo in which the angle of rotation can be directly passed as a parameter.
At the same time, a HIGH logic is passed to the pin connecting the LED indicator setting the LED ON. If the level of alcohol digitized to 10-bit value is less than 500, the servo is maintained at 0-degree angle and LED is kept OFF by passing a LOW logic at the respective pin.
Check out the Arduino code to learn how it manages to take the reading from the MQ-3 sensor, digitize and display reading, compare reading with a threshold level and operate LED as well as Servo to indicate the level of consumption beyond the legal limit.
Programming Guide -The Arduino sketch imports Servo.h for controlling servo motor and LiquidCrystal.h for LCD display. An object of LCD type is instantiated and assigned controller pins. Variables denoting LED and pin connection of MQ-3 sensor are declared and assigned controller pins. An object of servo type is declared and variables to store sensor value and servo angle are declared.
#include <Servo.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int ledPin = 12;
int sensorPin = A1;
Servo myservo;
int pos = 0;
int value;
The setup() function is declared which runs for once after the controller is powered on. In the function, the baud rate for serial communication with the LCD module is set to 9600 baud per second. The LCD object is initialized to 16 by 2 character LCD mode and the pin connecting LED is set to digital output using pinMode() function. The servo motor is rotated to 10-degree angle by default.
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(ledPin, OUTPUT);
myservo.attach(10);
}
The loop() function iterates infinitely. In the function, the sensor value is read using analogRead() function and stored in a variable. A message indicating current reading is printed on LCD. The value is compared with 500 and if it exceeds 500, the LED is set ON and the servo motor is rotated by an angle of 100. An alert message is printed on LCD. Otherwise, the normal value is printed on LCD and servo is maintained at 0 degree. The LCD display is cleared in each iteration.
The complete code for the Alcohol Detector Project can be found in the code section.
Comments