loading

For this project I made a breathalyzer powered by an Arduino UNO.

This is a novelty item, while it does give you a reading on your Blood Alcohol Content you should never rely on this and if you are unsure of how drunk you are please never drive home.

You blow into the hose, the LEDs tell you what level you are in (green, yellow, red) and then a receipt prints out telling you how drunk you are, and a number for a local taxi.

*FOR ENTERTAINMENT PURPOSES ONLY*

Step 1: Gather Materials

Materials for actual Breathalyzer:

Total= $116.55

Basic Supplies:

Total=

Supplies for Casing:

  • 1x11x8 Piece of wood- $8.99
  • Hinge- $2.78
  • 2 Hasps- $4.99
  • Nails- $2.99
  • Vinyl (for lettering)
  • Black Spray Paint- $3.97
  • Hookah Hose

Project Total= $165.83

*Paper not included. It is sold separately.

**Do NOT connect your thermal printer to your Arduino power, it WILL fry it. I learned the hard way.

Step 2: Setting Up Your LEDs

  1. First, you will need
  • 2 Red LEDs
  • 2 Yellow LEDs
  • 2 Green LEDs
  • 1 Blue LED

2. Next, cut 8 inches of wire per LED (7 strips total) and cut those in half. This will leave you enough room for the LEDs to reach the top of the casing.

3. Then, Solder the wire to the LED legs

  • I used brown wire for the short legs and black for the longer legs.

4. Repeat this for each LED

5. Next you will take a breadboard a connect a jumper wire from the GND pin on the Arduino to the GND on the breadboard. (Refer to Diagram)

6. Then you will connect the LEDs to the Arduino.

  • Pin 13>Breadboard>Resistor>LED Leg>GND (BLUE)
  • Pin 7>Breadboard>Resistor>LED Leg>GND (RED)
  • Pin 6>Breadboard>Resistor>LED Leg>GND (RED)
  • Pin 5>Breadboard>Resistor>LED Leg>GND (YELLOW)
  • Pin 4>Breadboard>Resistor>LED Leg>GND (YELLOW)
  • Pin 3>Breadboard>Resistor>LED Leg>GND (GREEN)
  • Pin 2>Breadboard>Resistor>LED Leg>GND (GREEN

Step 3: Setting Up Your MQ-3 Sensor

First you will get to know your sensor, the side that has the printed MQ-3 on the side is going to be your A Sensor side. The opposite side is the B Sensor side.

  1. On the A sensor side you are going to solder a wire (about 6 inches long) from each leg.
    • I recommend choosing 4 different colors. 3 wires of the same color on one side, and the other 3 should be 3 different colors as to not get confused.
    • On the A sensor side you will connect all 3 wires together.
  2. On the B sensor side you will take the furthest leg on the right and solder it to a 220 ohm resistor
  3. The middle 2 prong are H Sensors, this is because it is the heating element of the sensor.
  4. For the two remaining legs connect them to long wires.
    • Sensor A(1) Sensor H(1) SensorA(3)>5V
    • Sensor B(1)>A0
    • Sensor H(2)>GND
    • Sensor B(2)> GND

*Warning!!! The sensor takes up to 30 seconds to start up, this causes the metal top to become warm so do not touch it to your mouth.

Step 4: Setting Up Your Mini Thermal Printer

*****PLEASE BE AWARE THAT YOU NEED AN EXTERNAL POWER SOURCE FOR THE THERMAL PRINTER IF YOU CONNECT IT TO THE POWER OF THE ARDUINO IT WILL BLOW YOUR ARDUINO

AND YOUR MQ-3 SENSOR******

  1. The mini thermal printer from Sparkfun has a funny looking adapter on the bottom. For this project you will cut the 3 multicolored wires and solder them to wire that can be used for the breadboard.
  2. Then you will attach the other 2 red and black wires (5V and GND) to the Female DC Power Adapter. This requires no soldering. You can then plug this into a wall adaptor.
  3. The remaining wires will then be connected:
    • BLACK>VIN
    • YELLOW>RX0
    • GREEN>TX0
  4. To do a test print hold down the button on the thermal printer until the printer prints off a list of characters.

*Special Note*

After testing my code and breadboard wiring I began to solder, I accidentally connected to my GND and 5V wires to my breadboard causing my MQ-3 Sensor and Arduino to fry. I frantically bought another Arduino but sadly it was too late for my MQ-3 Sensor, please, learn from my mistake and do not apply this much power to your Arduino or it will fry. I could not present my final project due to this.

Step 5: Attaching On/Off Switch

I decided that since the printer drew so much power that an On/Off switch would be the best solution.

  1. First Solder two different colored wires measuring roughly 6 inches a piece to each leg of the On/Off Switch.
  2. Next, take your GND wire (black) from the printer and cut it in half and strip a half inch from each side.
  3. Repeat for the 5V wire (red).
  4. Solder the orange striped wire to both ends of the GND wire.
  5. Solder the orange and white striped wire to both ends of the 5V wire.
  6. Now you have a functioning On/Off Switch.

Step 6: Code

#include <Adafruit_Thermal.h>
#define qtyLED 6  //Declare the quantity of LED's for the bar graph
<adafruit_thermal.h><br>#include <SoftwareSerial.h><softwareserial.h>
SoftwareSerial mySerial(0, 1); 
Adafruit_Thermal printer(&mySerial);
int printer_RX_Pin = 0; 
int printer_TX_Pin = 1;
int LEDs[qtyLED]; //Array to store the states of the LEDs
int sensorPin = 0; //Variable that will hold the current value of the sensor
int time; //Variable that will hold the amount of time for the sensor to be read
int maxreading; //Variable to store the maximum value read during the last reading
//For loop counting variables
int i;
int j; 
void setup()
{
mySerial.begin(19200);
printer.begin();</softwareserial.h></adafruit_thermal.h>
  //Initialize the counting variables
  i=0;
  j=2;
  
  while(i < qtyLED) //While i is less than the number of defined LED's
  {                 //...save the value of i+2 in the LEDs array. we add 2 so that it represents one of our digital pins
    LEDs[i] = j;
    i++;
    j++;
  }
  
  for(i=0;i<qtyled;i++) define="" the="" led="" pins="" as="" outputs.="" in="" this="" case="" 2-="">7
  {
    pinMode(LEDs[i], OUTPUT);
  }
  pinMode(13, OUTPUT); //Define pin 13 as an output so we can show when we are not taking a reading from the sensor(Blinkin
                       //...Or when we are taking a reading from the sensor (Solid)
}</qtyled;i++)>
void loop()
{
  PORTB = PORTB ^ 100000;  //Invert pin 13 to give the LED a blinking effect
  delay(100); //Delay so that the user can see the blinking happen
  int sensor = analogRead(sensorPin); //Read the sensors value and store it in the sensor variable
  if(sensor >= 40) //If the value is less that 40(value for the chemical being used in this example)
  { printer.println("Breathalyzer 2.Arduino"); //printer will start and print the first statement (if the value is less than 40)
 printer.print("Hey! Look at you! ");
 printer.print("You are sober!! That's a shocker!");
 printer.feed();
 printer.println("Now quick, before your friends call you back over for that next shot you should just go home");
 printer.println("Doesn't Netflix and a bed sound fun?");
 printer.println("If that doesn't tickle your fancy and you plan on drinking tonight please call");
 printer.feed();
 printer.println("*850.433.3333*");
 printer.feed();
 printer.feed();
 printer.feed();
 printer.println("For entertainment purposes only");
 printer.feed();
    }
  {  
    digitalWrite(13, HIGH); //Turn on the blue LED indecating that the sensor detected a minimal amount of alcohol (sensor >= 40)
    maxreading = 0;         //Initiate the max reading to 0
    for(time = 0;time <= 5000;time++) //Read the sensor for 5 seconds
    {                                 //...every millisecond update the value of the max reading of the sensor
      int sensor = analogRead(sensorPin);
      delay(1);
      if(sensor > maxreading)
      {
        maxreading = sensor;
      }
   
    
    digitalWrite(13, LOW); //As soon as the reading is complete turn off the blue LED
    int level = map(maxreading, 0, 200, 0, qtyLED); //Map the value from 0 to 200(reading from sensor) to 0 and the number of LEDs which is 6
                                                    //...0 to 6(LEDs) level determines how many of them turn on.
    for(i=0;i<qtyled;i++) compare="" all="" the="" leds="" current="" state="" with="" value="" of="" level="" that="" was="" read=""  ="" {="" if="" for="" example="" 5,="" then="" 2-="">6 would turn on.
      if (i < level) //If the current LED being checked is less that the level
      
      { printer.println("Breathalyzer 2.Arduino");//printer will start and print the first statement (if the value is between 40 and the max)
 printer.print("Well well well....");
 printer.print("It looks like you've had a bit to drink. You should probably stop now. That's what all the cool kids are doing");
 printer.feed();
 printer.println("Besides, do you really want to be THAT GUY?");
 printer.println("Now, go pay your bar tab and please call");
 printer.feed();
 printer.println("*850.433.3333*");
 printer.feed();
 printer.feed();
 printer.feed();
 printer.println("For entertainment purposes only");
 printer.feed();{
        digitalWrite(LEDs[i], HIGH); //...Turn it on
        
      }
      }   
      else //If the current LED being checked is higher than the level
      
      {
        digitalWrite(LEDs[i], LOW); //...Turn it off
      }
       { printer.println("Breathalyzer 2.Arduino");//printer will start and print the first statement (if the value is at the maximum level)
 printer.print("HOT DOGGY");
 printer.print("You are as drunk as a SKUNK!!");
 printer.println("I could tell you pretty much anything right now and you wouldn't remember it");
 printer.feed();
 printer.println("fajksdfjalksfjalkdfja;l ");
 printer.println("Just Kidding! But Seriously, you should probably put that beer down and call");
 printer.feed();
 printer.println("*850.433.3333*");
 printer.println("It's bedtime.");
 printer.feed();
 printer.feed();
 printer.feed();
 printer.println("For entertainment purposes only");
 printer.feed();
    }
    }
    delay(10000); //Wait 10 seconds for the user to get the reading from the led bar graph
    for(i=0;i<qtyled;i++) turn="" off="" all="" the="" leds=""  ="" {="" digitalwrite(leds[i],low);="" }="" }<="" p=""></qtyled;i++)></qtyled;i++)>],LOW);
    }
    }
  }
}

Step 7: Making the Casing

  1. First you will use a saw to cut 4 pieces of wood measuring 11"x5" these will be used for the front, back, top, and bottom pieces.
  2. You will then cut 2 pieces measuring 7"x5" these will be used for the two sides.
  3. After you have cut and made sure they are all even you will sand down the edges to make them smooth.
    • This also helps with painting an even coat.
  4. You will then take one of the pieces measuring 11"x5" and measure out six holes each an inch apart and one hold directly above and centered. These holes will be used for the LEDs.
    • Make sure you sand after drilling these so that the wires do not get caught on the inside of the casing.
  5. Then you will measure out a three inch gap, this will be used to feed the receipt paper through.
  6. Very carefully take a drill and drill two holes on each end of the gap.
    • Next carefully use your jigsaw and cut a straight line all the way across on the topand bottom to easily removed the small piece of wood.
  7. On the smaller peices of wood you will take a drill and drill out a hole big enough for the On/Off switch and the hookah hose.
  8. Now its time to put the casing together.
    • Nail the 4 larger pieces of wood together and line them up with the smaller on the side. I used 3 nails per side to make sure it was sturdy.
    • Nail the small piece that you drilled into and nail it down.
  9. Since you want to be able to access your Arduino and Batteries you will want to drill the hinge into the small piece of wood and the other side into the larger piece of wood.
  10. To make sure that it stayed closed I added two hasps.
  11. Once it is all put together I filled in the gaps with some caulk.
  12. I spray painted the whole box with a metallic black paint.
  13. I used a cricut air to cut out some vinyl stickers to give it a more polished look.

Step 8: How to Operate the Breathalyzer

  1. Turn on printer. Using switch.
  2. Turn on Arduino.
  3. Watch for blinking Blue light.
  4. Wait 30 seconds for the MQ-3 Sensor to heat up.
  5. Once the light turns a solid blue it means that it is ready to detect alcohol.
  6. Rinse mouth in mouthwash and/or drink.
  7. Blow into hose.
  8. Watch LEDs light up.
  9. Read your comments.
  10. Call a cab.

Step 9: Stuffing the Insides

This is the tricky part. My suggestion would be to make sure all of your wires are color coated to make the take apart process easy.

  • For the LEDs I used a hot glue gun to keep them stable on the outside of the case.
  • I used a double sided tape to keep the MQ-3 Sensor in place.
  • On the back of most breadboards there is a sticky pad that adheres to the side of the wood holding it in place.
  • I used a command strip to hold down the printer and keep it from sliding around.

The hookah hose can wedge right in, but if you cannot get it to stay you can coat it with some hot glue to give the coarse wood something to stick to.

Step 10: Finished Product

If you have any questions feel free to comment and happy coding!

Hey i am trying to make this can you please help with me get the code to load to the board
Cool project. But I think that you colud've mounted the printer to the box and not leaing it inside.

About This Instructable

5,280views

69favorites

License:

More by cah65:Breathalyzer 2.Arduino Arduino Powered Fortune Teller 
Add instructable to: