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.
I wanted 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:
The first thing I did when I got parts in was to prototype.
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.
I also desoldered the power connectors on the charger board and soldered power connections straight to the solder pads which cut down height. After some careful checking that nothing would short, I screwed the whole thing together. Here’s a video of the first test:
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.
I only ran into one major problem. Once I realized I’d have to extend the USB port, I started soldering extension wires to the board. I got the polarity wrong, which promptly fried the charging chip. So I got another charger board and made sure everything was connected correctly. 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. After some more troubleshooting, I noticed that I could change the value of a resistor to increase the load I could pull. I changed the resistor, but was still pulling too much current. 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. If I ever combine everything on a single board, I’ll add some automatic switching to fix this in an elegant way.
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.