Creating a Breathalyzer with an Arduino and MQ-3 Gas Sensor

I got this idea after seeing all the available MQ-sensors at which each promised to detect a different gas.

Some Sensors Avilable

  • MQ-2 - Smoke Gas and LPG/Butane
  • MQ-3 - Alcohol/Ethanol. As mentioned in the datashseet to properlky calibrate these sensors you would need to be able to properly isolate the sensor in an area with an exact level of the gas you wish to sense for.So for alcohol have th sensor isolated in 0.4mg/l to gain a baseline. Fo rthis experiment the calibration was more ad-hoc.
  • MQ-6 - Made for domestic detection of Liquefied Petroleum Gas (LPG) or Liquefied Natural Gas (LNG).
  • MQ-7 - Carbon Monoxide detector (the one I thought could be used most usefully).
  • MQ-8 - Specifically designed to detect hydrogen leaks in the area of the sesor.
  • MQ-9 - Fo rtestiung for the presence of Carbon Monoxide (CO) and I had the idea later of trying to create an example carbon monoxide detector.
  • MQ-135 - This is a multi-purpose gas sensor capable of detecting gases including CO2, Alcohol, Benzene, Nitrogen Oxide, Ammonia (NH3), etc. You should be mindful of the attached callibration pot on the snsor and the datasheet when deciding what to calibrate for specifically.

Caveat and Warning

Though obviously none of the detectors I or any othe rmaker may build using these sensors has likely passed the stringent safety checked required to go to market they make for interested testing and calibrating of the sensor with your Arduino setup.


The setup was pretty simple and my fiurst decision was to use an Arduino Nano over the Uno as I didn’t need anywhere near the pins required of a full board.

See the Fritzig image below to see the wire up. You may notice a difference in the coloutr of the sires betwen mine and the diagram. Thats because I changed my mind during the diagram.

NOTE: Not all MQ sensors come with the same PCB breakout board pinouts. Be sure to double check the pins before hookup

Circuit Diagram

Here’s a link to the Fritzing file: /2018/02/Creating-a-Breathalyzer-with-an-Arduino-and-MQ-3-Gas-Sensor/circuit-design.fzz

Wiring Instructions

On the MQ-3 breakout board the pins are as follows (as it faces you):

  1. Vcc (+5V)
  2. Ground (GND)
  3. D0 (Digital)
  4. A0 (Analog)

Each connects into corresponding pins into the Arduino Nano. If the diagram isn’t clear then:

  • MQ-3 Pin 1 -> 5V Pin on Arduino
  • MQ-3 Pin 2 -> GND on Arduino
  • MQ-3 Pin 3 -> Digital 8 pin on Arduino
  • MQ-4 Pin 4 -> Analog 0 pin on Arduino

The LED lights up when ethanol/acohol is detected in the air. At base vcalibration this stayed unlit until I placed Bonjela and Alcohol hand wash near the sensor at which point the LED lights up.

Watching the serial monitor als shows the Analog reading coming from D8 increases at the presence of the alcohol sources. The biuggest imcrease was seen by being placed near Bonjela. Contrary to my original hypothesis.

Starting analog readouts are around 1-200. When alcohol is introduced this increases to around 7-800.

Arduino Source

The source was written usining PlatformIO whose source is saved in *.cpp files. They have a single header at the top


All Photos Of Project As Finished

See the photos with the semi-completed projct in this Google Album Link:

Or check out thesre one or two to see how they turn out:

Opportunities For a Skills Refresh

Although some of my recent projects have provided the opportunity stretch my muscles in Laravel, Google API integration, Google Apps Scripting and various other areas I felt it was time for a more structured and comprehensive review of my techgnical skills. Thats one point I will make clear here is I’m focusing on technical skillset and not others like PM or marketing. Those will be part of another post or time as I’ve had plenty of experience in those and they by their nature move slower in development and change than the webs technologies.

So where to go to go to boost your web skills in 2017?

I’ve already heard of the common skills game websiutes such as Code Wars but I also wanted to take the chance to learn some different but related areas. Maybe in cloud computing and definitely motre in and area I’ve felt lacking in a while and thats frontend JS frameworks.

A good introductory place for heklping to compare some of the places I mention below is a new-wishg site: Slant which is great for finding out crowd sourced opinions on various technical subjects.

Google CodeLabs

  • FREE programming resource!
  • Covers a narrow selection of the latest technologies being pushed by Google
  • Link

Absolutely my favourite in the list as it covers a lot of new techology Google is trying to push such as Progressive Web Apps, Accelerated Mobile Pages, Pushg Notifications to web apps, Web Assembly and much much more. Not only that it’s all free and really great quality with step by step video guides to c9ompleting each project.

They also cover a huge range of categories including Web, IoT, Search, Cloud, Geo and many more. All with duration estimates and a finished product. From there you can obvuiously adapt it or use the techniques on your existing projects.

For example a Service Worker codelab is helping me to speed up some of our Bridgestone sites adding modern Progressive features.

One thing I found lacking in Google CodeLabs is a lack of depth. For example I wanted to create a 3 page Polymer 2.0 app using the
Corousel tutorial. It was only one page of a 3 page app but evenb this small tutorial had me stumped at the firts hurdle. Nothing was styling right, things weren’t iubncludiung correctly. It turns out I needed a beginners course in Polymer. So I dove into one of the other courses butr again hit the same hurdle. Even the ones titled something like “from scratch” didnm’t help much more.

They all seemed to expect some semblence of knowledge for every tutoriual which left me feeling a little stupid and moved onto other area.

CodeLabs are great for scrubbing up and polishing yourexisting knowledge but they aren’t great for learning new techniques.

Cloud Academy

  • 7 day free trial to the courses
  • from $59 p/m
  • Link

This service cost is a little steeper especially cosnidetring it only covers Cloud Computing but but it does scratch that itch of doing something different. It offers a large library of courses into cloud computing generally as well as specific course pathways that cover one of the the 3 major cloug computing platforms AWS, GCP or Azure.

I cancelled my Cloud Academy free trial pretty quick as I noticed Azure was offering a free Azure course at PluralSight and the cost for the relkatively narrow focus just couldn’t be justified. Maybe if I was focusing on a complete career change in the future I could imagine it but for now it seems a bit OTT.


  • 10 day free trial to the courses
  • from $29 p/m
  • Link

There’s so many things I love about this service that I’ve seen grow over time. As I write this blog post I’m wondering why haven’t I signed up for this fully already. I’ve had a few free sign up periods but never kept my subscription for some reason or another. But the sheer numbver of coutrses on everything from tech to cloud to project management is insane and it truly sells itself. I swear I dont’ rememebr PM being one of the learning courses on here before but it is now.

On top of that yoyu can now monitor what you know and don’t know. Find skill gaps you need to fill. Its other main competitors don’t really touch it (Team Treehouse & Code Academy are both for simpler concepts).

They have online interactive technical labs where you can try out what you’re learning as well as a mobile app to watch the videos that go with the courses.

I’d probably recommend this over Cloud Academy first and do Cloud Academy more as a specialisation at a later date because this does have some cloud-based courses.


There’s tons more I haven’t mentioned in this roiundup as I’ve found I’m starting to be paralised by choice. I just need to sit down and pursue one or two and complete the courses otherwise none will get done.

I may do anoter list of these in the future including CodeSchools, CodeAcademy, EggHeads, StackSkills, etc.

Hexo Deezer Tag Updated

Hexo Logo Version 1.0.6 has been released of the latest Hexo Deezer Tag plugin. This was mainly a maintenance update to include the latest changes in Hexo by Tommy351. These included project-specific styling and linting.


I’m a big believer in uniformity of coding styles within projects and its associated extensions and think it important that core projects standards overrule your own personal views.

Using Changes

As this is mainly a change to the development of the plugin you won’t be able to see any changes to the plugin on your site. It just makes the plugin a little more robust, clearly displaying status and preparing for some major refactoring to implement proper testing of the plugin (using Mocha) along the lines of my other Hexo extension the Hexo Deezer Playlist Helper for templates.

The changes will be immediately noticeable on the Deezer Tag page. But you can also check them by cloning the repo and running the npm commands:

git clone
cd hexo-tag-deezer
npm install
npm run eslint
npm run jscs


Grimes is currently touring!

Useful Git Aliases

Git LogoIf I ever start at a new job where I’m given a new Mac I always set up these aliases. I’ll list them with their output then at the end provide a gist of them you can add to your own aliases.

If you’re on a Mac with OSX then you will find your aliases in ~/.gitonfig

You can add aliases with the following example:

$ git config --global checkout

Without further a…oh sod that cliche. Here’s my aliases:

a = add
b = !git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'
c = commit -m
cob = checkout -b
devs = shortlog -n -e -s
ds = diff --staged
l = log --graph --pretty=format:%C(yellow)%h\ %ad%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=short
ll = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold yellow)— %an%C(reset) %C(bold blue)<%ae>%C(bold red)%d%C(reset)' --abbrev-commit --date=relative
panic = !tar cvf ../git_panic.tar *
rao = remote add origin
s = status -s
tidy = !git gc && git clean -dfx && git stash clear
undo-commit = reset --soft HEAD~1
wdiff = diff --word-diff=plain
who = shortlog -n -e -s

Here’s a gist of my current aliases:

Using tmux and tmuxinator to organise projects

If you’re anything like me and have a problem with names - not just people - but projects too. Or if you find yourself losing track of projects because of different languages or editors used.

You may find your saviour in the tmux + tmuxinator combo.

When discovering virtualenvwrappers workon command for managing Python projects I was immediately envious of it’s functionality; wishing it was available for other projects.

I wanted a similar app that could launch prepared editor environments. While being flexible enough to change editor on a whim. I often switch between Vim, Sublime and Atom depending on mood and weather. If I’m feeling especially masochistic I’ll setup a project in PHPStorm (leave hate mail below).

Next, something that could store my code locations as I had several. Including ~/Dev ~/Development ~/Sites - don’t ask me why. But also remote locations accessible only via FTP, SSH or some other arcane method.

Now with anything from 2 big to 20 small projects on the go for work and around 20-30 small home/hobby projects its not suprising I got muddled.

In my idle wandering I came across the aforementioned tmuxinator which ticked ALL the boxes using a tool I already used (tmux).


tumx is like Screen but 10x better. If you’re still using Screen then switch to tmux. If you’ve never heard of Screen then…pretend I said nothing and use tmux!

tmux enables you to save multiple virtual consoles. In a basic way it can help you save your place in an terminal session. This is great for unstable SSH connections. If the session dies then normally you lose everything including spawned processes, etc.

But if you were in a tmux session then its all saved as ts all executed from the tmux process. tmux becomes more profound as you use it. When you combine it with Tmuxinator you suddenly realise you are capable of taking over the universe (or something similar)


Tmuxinator gives you all the power of Tmux but with configurable states. So you’re no longer restricted to just saving your last state said but you can set up your own states. Your terminal, and to an extent your system, can be setup for a particular project.

tmux and tmuxinator gives unlimited power

Put another way it gives you that workon used in Python I mentioned earlier with unlimited power.

Imagine you have my hobby project-nest and you are wondering what to do today with your 30+ hobby projects. Do you want to spend 10, 20, 30, 60, minutes hunting for the one you last worked on about 6 months ago whose name began with p?

Oh god you’re sure it was in that folder with other Node experiments maybe or?

You don’t have to remember once you’ve set up a tmuxinator config file in YAML.

All it takes then is:

% mux list

tmuxinator projects:
awin-feeder fspart myblog ukp

And all it takes is mux open myblog to open up that project.

Here’s an example of the tmuxinator project file for this blog:

name: myblog
root: /Users/doug/Sites/dougbromley/blog

- editor:
layout: main-vertical
- subl --project myblog.subliime-project; clear
- hexo --help
- genwatcher:
layout: main-vertical
- hexo generate -w
- hexo serve
- gitstats:
layout: main-horizontal
- git ll
- git cal
- git summary

In the above its:

  1. Opening the a basic vertical layout
  2. Then in the main pane its opening Sublime with my blog as the main project so I can start editing straight away.
  3. In a separate pane the hexo help command is run to remind me of hexo’s commands.
  4. In another window the hexo local server is run.
  5. In that same window another pane with hexo generate is run with the watch flag so I can see changes regenerated live.
  6. In the final window is a set of panes giving some git info - I often find this useful to remind me where I left the project.
Session Screenshot of Window gitstats

In the past all of these sequences and processes would have to be remembered but if you have multiple projects it can become a burden to remember them all.

Tmuxinator along with tumx makes things much simpler.