Let’s get #atmega_drunk

IMG_20150207_153058

Being quite new to the arduino world it always amazes me when I find out about a new sensor and there uses. A few years ago I seen this really cool hack where a guy put an alcohol sensor and a Teensy 2.0 into a party buzzer. This is where I got the idea to get a MQ-3 alcohol and start playing with it. I wanted to turn the breathalyzer into a game to see who could get the highest ‘score’ that’s when my journey begun into making #atmega_drunk

The sensor

IMG_20140908_211324

Being a cheap skate I ordered my MQ-3 sensor direct from china so I had a while to wait for it to come so I did some research, Most people recommend you “burn” the sensor in for 24 hours. So connect it up to the 5v and GND lines on your arduino/uC and let it burn in, This will make sure that any chemicals are burn off that were used in the manufacturing process and let the sensor settle in.

20141224_112232

 The screen

I’ve been eyeing up those OLED screen since I had gotten bored with using the 2 x 16 character LCD screen I had been using. I opted for a 128 x 64 pixel screen that had .96″ diameter and monochrome. I ordered a generic one from eBay but found that I could get it working with adafruit library’s found here and here

IMG_20141124_135026

What I love about this screen is there is so much space to add text and there is a choose of font sizes with the library too. I haven’t had change to look into making custom images for the display.

The micro processor

When people ask why do you use that micro controller most people will reply that they use what they know. This is why I’m using the forever faithful Atmega328 as found in an arduino. I’ve use this uC in the last 2 projects so I’m getting more confident in laying out my circuit and knowing what passives I need. Another reason I used the Atmega328 is that its really easy to add USB by adding a FTDI board

The layout

After all my parts arrived and I settled on the amount of buttons I could start bread board testing. Here is my layout and full res version are available here on my github

atmega_drunk_bb

 Enclosure and PCB

As with all my projects lately I breadboard (pictured above) the circuit, then layout a PCB using kicad. Before designing my PCB I need to find an enclosure. The design of enclosures have come along way and the ones coming out of china look really professional and not look like an amateur project box. I was struggling to get an enclosure that would be big enough to fit anything but not to big it wouldn’t look to big to be a handheld device. I’ve never looked at the aluminium extruded enclosure before but with every project I try to push myself to try something new.

20141216_115541

This is the one I picked mostly because it come in two half’s and didn’t have to be slid together so it would make it easier to assembled. The PCB is slides into a groove so I had to get the width of the PCB right or it wouldn’t fit.

IMG_20150112_211005

lucky for me when I got the PCB back from oshpark It fitted like a glove and left just enough room underneath the PCB for the through hole parts.

Battery

For all my other projects I had used replaceable battery’s or it had been powered off the mains but with this I wanted to make it rechargeable.  I picked a 18350 battery and to charge it I striped out the circuit out of power bank which allowed me to recharge and pull power from the battery at a steady 5 volts

IMG_20150128_100307

I had to wire up a custom cable so that i could charge and upload sketches via the same USB port. I found a female USB b port that could be mounted to the enclosure. I split off the GND and 5V lines off to the battery charging circuit then to a mini usb cable into the FTDI board. There was one problem with this, when I powered the #atmega_drunk on it would start charging the battery from the battery. This was because the 5v would come out of the FTDI board so I added a diode so power would only go into the FTDI board and not come out of it.

IMG_20150129_105738

Coding

I found myself with a bit of a dilemma, If I wanted to write and test the code I would need to be drinking but the more I drunk the worst my code gets. I did start by testing my code with an open bottle of jagermeister but it wasn’t a real world test. I had to write my code for the night then have a few drink to see if it worked. One night I spilt some cider on my MQ-3 alcohol sensor and after that it wasn’t reading as actuate so I had to order a new one and that fixed the problem so don’t be doing that lol. I put all my code up on github so feel free to reuse my code in your project.

After I got the basic code laid out I decided to have a little fun and add a bit of polish to the layout and add some phases to the drunk scale. This is where I ran into the limits the graphics library I was using, I run out of storage on the screen but with a bit of text shortening I just made it fit. I did find a text only library here which works for a few popular screen. I took the time to rewrote my code with the text only library and didn’t run into any of the problems I did with the adafruit library

Assembly

With this being my first aluminum enclosure build I was a little apprehensive in starting to layout where the buttons, screen and sensor was going to go. As mentioned earlier I first sorted out my custom charging/FTDI cable which was a task within its self. Being the cheap sake I ordered a 16mm hole saw from china to cut the hole for the sensor, being from china it turned out to be 15.5mm lucky I had a round file to sort it out.

IMG_20150122_154244

Next up I started populating the PCB. At first I was going to have the FTDI board coming off the PCB but I found I didn’t have much space in that direction. So I found that if I turned the PCB around I could have the FTDI board going over the top of the PCB so It saved space.

IMG_20150126_102729

The thing I was dreading the most was cutting a hole for the screen to show though. I was really happy with the way it came out but I think that’s to do with my ever critical eye. The screw holes are a little off.

IMG_20150130_102517

The buttons were next on the list. I had the on/off one on top plus two face buttons. I had to put some heat shrink tubing on the wire to give it some give while I manipulating the build plus I covered any solder points with kapton tape so it wouldn’t short anything out.

IMG_20150131_154810

All that was left to do was cram it all into the case and hope that it works after it’s all screwed together lol

IMG_20150131_155143

Video

Here’s a quick demonstration video of it in action hope you enjoy

Advertisements

One response to “Let’s get #atmega_drunk

  1. Pingback: Electro_pet | Facelesstech·

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s