Introduction: DIY Portable Breathalyzer - Submitted by BayLab for the Instructables Sponsorship Program
Detect your BAC wih a pocket sized breathalyzer.
Step 1: Disclaimer
Before we start, a disclaimer. This is NOT meant to be used to tell if you are ok to drive or not. It is not as accurate as a police breathalyzer and should not be used as one. If you drink, DO NOT DRIVE!
Step 2: Design Requirements and Parts List
This is a small project I did over the course of about two months of on and off work while in school. My friend was turning 21, so this was my gift to her. I designed the schematic in a couple of hours and had several features in mind. I wanted it to be relatively small so she could have it in her pocket or purse. I also wanted it to be self contained. Because I wanted it to be as small as possible, I knew the enclosure was going to be crammed with stuff. I didn’t want her to have to take the thing apart and replace batteries, so I decided it needed a rechargeable one. I always hate it when I have like 50 AC adapters (wall warts) to charge various devices, so I wanted to make the device charge over USB. I wanted the interface to be as simple as possible, and came up with a way to do it with only one button. Unfortunately, I ended up having a problem with this which I’ll talk more about later. The last thing I wanted was a nice big screen to display sensor data on.
- Cast Aluminum enclosure with lid (4.5″ x 2.6″ x 1.2″). This was the smallest enclosure I could find that had a lid large enough for the LCD screen I had.
-Arduino Micro Pro. Chosen for it’s insanely small size. It’s barely taller than the PCB itself.
-FTDI cable. The Arduino Micro Pro doesn’t have a serial to USB chip like full sized Arduinos, so you need this to program it. Basically the chip is in the cable.
-USB Lipo Charger. This is a nifty part from Adafruit to charge Lipo batteries. It’s got some protection built in which is good because Lipo’s can be dangerous if you’re not careful. The only thing I don’t like about this board is that it’s kind of large. The charging IC is really small and I think they could have made it smaller. The height is good though.
-DC to DC step up. Everything I used except the alcohol sensor was 3.3v, so this booster let me run 5v to the sensor.
-3.6v, 1200 mAh Lipo battery. Nice and thin, and enough power to run the breathalyzer for a long time.
-128×64 Graphical LCD screen. Since it’s graphical, it allows individual pixel addressing. That meant I could add graphics easily. It also has a backlight.
-MQ-3 alcohol sensor. Weird pinout, but simple to use once you figure it out.
Step 3: MQ-3 Sensor
anted to take a minute to talk about the sensor I used, since it’s a little quirky. Here’s a great post that gives the details of how to connect the sensor to the Arduino and how it works on a chemical level. Even if you aren’t going to build something using this sensor, I recommend checking it out because it’s really interesting. Essentially, it uses heat to vaporize the ethanol in your breath to acetic acid. This changes the resistance of a semiconductor, which you can easily detect with a microcontroller. It’s pretty hard to break these things. They do, however, get a little hot. Be mindful of that when including them in your design, because you don’t want to burn the user. The other thing you need to do is “burn in” the sensor by running current through it for about 48 hours continuously. The data sheet recommends this and it improves accuracy and response a lot. If you want to skip reading the post, here’s a schematic of how to hook the sensor up:
Step 4: Electronics Testing
Since this is going to be crammed inside a small enclosure, it's better to work out the electronics bugs beforehand. I recommend prototyping the circuit on a breadboard and making sure that everything works and your code runs before soldering it together.
Step 5: Enclosure
Once I got the prototype working, I started getting the enclosure ready. I used the Chevalier mill in our robotics shop to mill out a hole in the lid to fit the screen. I also milled out a hole for the alcohol sensor, the USB port for charging, and both buttons. Once the screen fit, I attached the Arduino directly to the back of the screen using some double sided foam tape. The tape is great since it’s not conductive, provides a little shock absorption, and sticks well to FR4. I also stuck the DC booster on the back of the screen. Since everything was so close together, it was easy to solder the connections with some thin wire. I next installed the sensor itself which was press fit.
I then realized that I hadn’t taken the thickness of the enclosure into account for the USB port. Since the port is soldered flush with the edge of the circuit board on the charger, I had to solder some extension wires to it and attach it to another USB port that fit in the hole I milled. Make sure you get the polarity of those wires right or else you'll kill the charging board (like I did).
I noticed that while there was no load on the board, it charged the battery fine. Once I connected the output to the rest of the circuit, it wouldn’t charge. So I was forced to add toggle switch. When you charge, the switch is off and the charger has no load. When you turn the switch on, power is drawn from the battery, but it won’t charge. Because I didn’t have a lot of time to solve this problem, the switch was kind of a quick and dirty fix. You can either use the switch method or find a charging board with a higher current capacity, or implement a more elegant autoswitcher.
Step 6: Software
I wrote a simple program to take in the value of the sensor and show it on the LCD screen. It shows the raw value, a horizontal bar graph, and some text that tells you how drunk you are. I found out that the sensor isn’t very, well, sensitive. Because it’s not nearly as good as a police breathalyzer, I made sure to put a little disclaimer when you turn it on that tells the user they shouldn’t judge whether or not they should drive based on the results. And because I could show images on the display, I added a little splash screen that shows the name of the girl I made it for and her sorority letters. I had to get this thing to her by her birthday, so I didn’t have time to add all of the features I wanted to in software. In the next upgrade, I’ll add a better routine for calibrating the sensor and tuning it for her specifically. I’d also like to refine the way of displaying the sensor values to make it look a little more interesting. Originally, I wanted a single button to control the entire device. It was a momentary pushbutton. Once held down for a few seconds, it would send the ATMega into sleep mode. This basically makes the core only draw a few nanoamps. Pressing the button again triggers an interrupt that wakes it up. Because of a problem with the charging circuit, I ended up not being able to use this feature.
Here's my code.
Step 7: Modification Ideas
I think I could make the entire thing much thinner if I custom made the enclosure. I guess the best way to do that would be either 3D print it or water jet some aluminum and put it together with tabs. I’d also like to make my own PCB and combine the DC step up, microcontroller, and battery charger into a single board. I think doing that would let me get the entire device down to about .5″ thick. I also want to use a better LCD screen. Maybe a higher resolution color screen. There are lots of other neat mods you could do to this project and I encourage the reader to make this project as awesome as possible!