Alcohol Sensing Using MQ-3

About: An Electronics engineer and a hobbyist. I love to keep experimenting with microcontrollers.

Hello guys and welcome to another tutorial. Today we will learn to interface an oled screen with Arduino and also bring the MQ-3 sensor to some use (which was lying around in my house for almost a year now). The working of this project is quite simple. The MQ-3 sensor senses the presence of alcohol content and then sends an analog value to the arduino. And using an i2c based oled display I just printed that value on the screen. Now previously I made a video on the nokia 5110 lcd which showcased a game which I created. You can check it out by CLICKING HERE. If you want to see something similar using this screen then drop a comment below. Now let's get to work !!!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Gather the Components

I suggest you buy the components from UTSource.net . They provide high quality components & modules at affordable rates and deliver them at your door step on time. They also provide PCB DESIGN Services. You can get Pcb's made up to 16 layers and that too in very low prices. Do check them out.

Avengers... Assemble ! Lets get back to the topic. The things we need to make this project are as follows -

1. Arduino Uno Board

2. Bread Board

3. MQ-3 Sensor

4. Connecting Header Wires

5. And you also need some alcohol to test the project. If you don't have access to that then you can also use IPA or deodorants like I used here.

Step 2: Circuit Diagram

As the number of modules interfaces here are less so the connections are also quite simple.

Connect the Vcc and Ground of the MQ-3 sensor to 5V and Gnd pin of the Arduino Respectively. Connect the Analog output pin of the sensor to analog pin A0. Now connect the Vcc and Ground of the oled to the 3.3 V and Gnd of the Arduino. And connect the SCL and SDA pins of the display to that of the Arduino i.e. A5 and A4 respectively.

For more help refer the circuit above.

Step 3: Code

The code for this project is given below.

You need to download the Adafruit_GFX.h and Adafruit_SSD1306.h libraries for this code to work. Befor uploading the main code connect the i2c display to the board and upload a i2c scanner code to find the i2c address of the device. And change that address in the main code.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h> #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); const int Asen = A0; #if (SSD1306_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif void setup() { Serial.begin(9600); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //The address of your i2c device display.display(); delay(100); display.clearDisplay(); } void loop() { delay(500); int val = analogRead(Asen); Serial.println(val); display.clearDisplay(); display.setCursor(18,0);//(COLUMNS,ROWS) display.setTextSize(2); display.setTextColor(WHITE); display.print("ENGINEER"); display.setCursor(48,15); display.print("KID"); display.setTextSize(2); display.setCursor(0,31); display.print("MQ3 SENSOR"); display.setTextSize(1); display.setCursor(0,50); display.print("ALCOHOL VALUE :"); display.setCursor(90,50); display.print(val); display.display(); }

I have also attached the .ino file below. Feel free to download it.

I have a small suggestion for you guys. Try out mapping the analog values to percentage so that you can display the alcohol content directly on the screen. I didn't had any alcohol so I didn't do it. There is just one instruction for that. I entrust that task upon you.

Step 4: Working Video of the Project

The video of the project is attached here both in mp4 and .gif format. Take a look how the project works. BTW the MQ-3 sensor gets a bit hot as it has to sense the vapor in the air so take that into consideration before putting it in some kind of enclosure. So hope this tutorial helped you. If it did then please share it on your social media handles and let your friends know what you are planning to work on. Also follow me here to see my upcoming projects. That's it for today, see you guys soon with another project.

Be the First to Share

    Recommendations

    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    Discussions