Build it step by step
0 of 6 doneWire the module
Connect power, AO and the three LEDs through resistors.
Burn in the sensor
Power it for a few minutes (ideally some hours the first time) so it settles.
Check the baseline
After warm-up, note the clean-air reading on Serial or the screen.
Test with a safe source
Hold a cotton bud with a little hand sanitiser near, not touching, the sensor.
Adjust the levels
Change the 80 and 200 limits to suit your sensor's sensitivity.
Label the box
Print "Demonstration only, not a legal breathalyser" on the case.
How do you build a breath alcohol tester?
An MQ-3 sensor gives a relative alcohol reading when you blow on it, with green, yellow and red lights. A demonstration only, not a legal breathalyser. You need Arduino Nano, MQ-3 alcohol sensor module, LED 5 mm green, LED 5 mm yellow, LED 5 mm red, Resistor 220 Ω × 3 and SSD1306 OLED Display. It takes 6 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 7
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- SemiconductorsBuyLED 5 mm green × 1
- SemiconductorsBuyLED 5 mm yellow × 1
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 3
- DisplaysBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| MQ-3 module VCC, GND | Nano 5V, GND | Power (the heater draws about 150 mA) |
| MQ-3 module AO | Nano A0 | Analog output |
| OLED SDA, SCL | Nano A4, A5 | I2C |
| OLED VCC, GND | Nano 5V, GND | Power |
| Nano D5 | 220 Ω resistor then green LED, to GND | Low |
| Nano D6 | 220 Ω resistor then yellow LED, to GND | Medium |
| Nano D7 | 220 Ω resistor then red LED, to GND | High |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "U8g2". The MQ-3 also responds to breath humidity, mouthwash and other vapours, so figures are only relative. It is a classroom demonstration and must never be used to decide whether it is safe to drive or work.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <U8x8lib.h>
U8X8_SSD1306_128X64_NONAME_HW_I2C oled(U8X8_PIN_NONE);
const byte SENSOR = A0, LEDS[3] = { 5, 6, 7 };
int baseline = 0;
int avgRead(int n) {
long s = 0;
for (int i = 0; i < n; i++) { s += analogRead(SENSOR); delay(10); }
return s / n;
}
void show(const char* a, const char* b) {
oled.clear();
oled.drawString(0, 1, a);
oled.drawString(0, 4, b);
}
void setup() {
for (byte i = 0; i < 3; i++) pinMode(LEDS[i], OUTPUT);
oled.begin();
oled.setFont(u8x8_font_chroma48medium8_r);
show("Warming up", "2 minutes");
delay(120000UL); // MQ-3 needs time to heat
baseline = avgRead(50); // clean-air reading
show("Ready", "Blow for 5 s");
}
void loop() {
if (analogRead(SENSOR) > baseline + 30) { // a breath is detected
int peak = 0;
unsigned long start = millis();
while (millis() - start < 5000) { int r = analogRead(SENSOR); if (r > peak) peak = r; delay(20); }
int rise = peak - baseline;
byte level = rise < 80 ? 0 : (rise < 200 ? 1 : 2);
for (byte i = 0; i < 3; i++) digitalWrite(LEDS[i], i == level);
const char* names[] = { "LOW", "MEDIUM", "HIGH" };
show(names[level], "Not a legal test");
delay(8000);
for (byte i = 0; i < 3; i++) digitalWrite(LEDS[i], LOW);
while (analogRead(SENSOR) > baseline + 10) delay(500); // wait for clean air
show("Ready", "Blow for 5 s");
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Clean air | Ready, no LED |
| Sanitiser near sensor | LED goes up with strength |
| Normal breath | Little or no rise |
| Wait after use | Screen waits for the reading to fall before the next test |
If it does not work
Always High
The sensor has not warmed up, or the baseline was taken near a vapour.
Never rises
Check AO to A0 and the 5 V supply.
Readings drift
Humidity and temperature change MQ-3 values. Re-take the baseline.
Screen blank
Check the I2C connection.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the breath alcohol tester?
Arduino Nano, MQ-3 alcohol sensor module, LED 5 mm green, LED 5 mm yellow, LED 5 mm red, Resistor 220 Ω × 3 and SSD1306 OLED Display.
How long does the breath alcohol tester take to build?
About 60 minutes for a beginner maker, in 6 steps.
How do I know the breath alcohol tester works?
Clean air: Ready, no LED. Sanitiser near sensor: LED goes up with strength. Normal breath: Little or no rise.
Always High: what should I check?
The sensor has not warmed up, or the baseline was taken near a vapour.
Never rises: what should I check?
Check AO to A0 and the 5 V supply.
Readings drift: what should I check?
Humidity and temperature change MQ-3 values. Re-take the baseline.
Screen blank: what should I check?
Check the I2C connection.
