Project in progress

An alcohol tester with LED lights made with Zerynth © GPL3+

How to build a device for estimating blood alcohol content from a breath sample. Developed with Zerynth and an ARM board.

  • 5,347 views
  • 3 comments
  • 31 respects

Components and supplies

Apps and online services

About this project

In this project we explain how to create a breathalyzer for estimating blood alcohol content from breath sample using Zerynth to program the board.

We used an Arduino Due but it is possible to use other ARM board as Particle Core and Photon and ST Nucleo, with the same code because Zerynth is multiboard. 

Our breathalyzer has 9 LEDs; 3 green and 6 red. They light according to the alcohol concentration read by the sensor MQ-3. The system must be calibrated by setting the values of the calibration array in the code and through the resistors. Otherwise you can use a potentiometer. The aim is having only the 3 green LED light when the concentration is under a fixed level.  


Hardware Set up

1. Connect the power to the Vin pin and ground rails to the GND pin on the Arduino Due.

2. Connect the anod of the led to the pin 4 (to re-use our code) and the cathod to the ground rail of the breadboard using a 220Ω resistor. See the circuit diagram for more details. Repeat to connect the other LED's from pin 5 to 12.

3. Connect the sensor as shown in the specified scheme:

  • Connect the B pins and one of the H pins of the sensor to the 5V output of the board.


  • Connect the other H pin to the ground.
  • Connect the A pins to the breadboard before the two serial resistor (4.7K and 10K ohm) as in the scheme.
  • Connect the A0 analog in to the breadboard among the two serial resistors (4.7K and 10K ohm).
  • Connect the end of the serial resistors to the ground (as in the scheme).


The Hardware is ready!


Code

Download and install Zerynth Studio from www.zerynth.com/zerynth-studio/ (it runs on Windows, Linux and MAC OS).

Zerynth allows to program ARM board as Arduino Due, Particle Core and Photon, ST Nucleo in Python, that is an high level programming language really simple and clear. Zerynth allows to bring Python ease and portability to the embedded devices.

So, paste the code in the IDE, virtualize your board and upload the code to the board.

Your breathalyzer is ready to use!


DISCLAIMER

This project is not accurate enough to register the exact value of blood alcohol concentration. It also is sensitive to environment temperature and humidity. It isn't a professional instrument. So we recommend: if you drink, don't drive!



Code

An alcohol tester with LED lights made with ZerynthPython
Paste this code into Zerynth Studio.
import streams
import adc

q=streams.serial()

digitalout=[D4,D5,D6,D7,D8,D9,D10,D11,D12]
calibration=[2000,1800,1600,1400,1200,1100,900,750,500]
min=750

for pin in digitalout:
    pinMode(pin,OUTPUT)

while True:
        alcool=adc.read(A0)
        
        if(alcool<=calibration[8]):
            on=[D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[7] and alcool>calibration[8]):
            on=[D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[6] and alcool>calibration[7]):
            on=[D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[5] and alcool>calibration[6]):
            on=[D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[4] and alcool>calibration[5]):
            on=[D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[3] and alcool>calibration[4]):
            on=[D7,D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[2] and alcool>calibration[3]):
            on=[D6,D7,D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[1] and alcool>calibration[2]):
            on=[D5,D6,D7,D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool>calibration[0]):
            on=[D4,D5,D6,D7,D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        sleep(500)
        print(alcool)

Schematics

Alcohol Test Circuit
Alcooltestcircuiti

Comments

Similar projects you might like

CPU and RAM Usage Monitor

Project showcase by thesahilsaluja

  • 1,209 views
  • 10 comments
  • 8 respects

AWS - Arduino Weather Station

Project tutorial by GilettaStefano

  • 5,447 views
  • 11 comments
  • 20 respects

Arduino Sunflower: An Electronic Sun-Dancer

Project tutorial by SURYATEJA

  • 2,740 views
  • 2 comments
  • 10 respects

Backpack Alarm

Project tutorial by Tomi Chen

  • 2,576 views
  • 12 comments
  • 28 respects

Arduino Based Security System

Project tutorial by Abishek Bhalaaji

  • 1,362 views
  • 5 comments
  • 8 respects

Hiking Tracker

Project tutorial by Shahariar

  • 5,082 views
  • 15 comments
  • 37 respects
Add projectSign up / Login