Didier Stevens

Wednesday 9 September 2009

QuickPost: Arduino + Alcohol Gas Sensor + WiShield + LCD

Filed under: Arduino,Hardware,Quickpost — Didier Stevens @ 20:07

This is a little project I’m working on for Brucon:


This is an Arduino with a WiFi adapter (WiShield), an LCD and a gas sensor (senses gases like ethanol).

What it does: the Arduino reads the sensor (uncalibrated for the moment), displays its value on line 1 of the LCD and also servers it on a web page (with an embedded webserver connecting to the WiFi network via the WiShield).
If the sensor read-out is 900 or more, a LED is turned on.
And I can send a message via the webserver to line 2 of the LCD.

The problem I had to solve: the LCD didn’t work when the WiShield was operating.

The cause: the WiShield library and the LCD library use some common pins.

Solution: change the pin assignment in the LCD library code (LCD4Bit.cpp):

// --------- PINS -------------------------------------
//is the RW pin of the LCD under our control?  If we're only ever going to write to the LCD, we can use one less microcontroller pin, and just tie the LCD pin to the necessary signal, high or low.
//this stops us sending signals to the RW pin if it isn't being used.
int USING_RW = false;

//RS, RW and Enable can be set to whatever you like
int RS = 1;
int RW = 11;
int Enable = 0;
//DB should be an unseparated group of pins  - because of lazy coding in pushNibble()
int DB[] = {3, 4, 5, 6};  //wire these to DB4~7 on LCD.


And don’t forget to delete LCD4Bit.o before recompiling the code. The Arduino IDE doesn’t check dependencies of libraries when compiling.

And yes, once calibrated, you should be able to use this alcohol gas sensor to prevent drunk e-mailing πŸ˜‰ But you’ll need to add a sensor to verify you’re actually blowing into the alcohol gas sensor. For example a gas pressure sensor.

Quickpost info


  1. Sometimes I could really use an alco-lock in my mail program! πŸ˜‰ Nice gadget. It would be even cooler if it could power itself from a USB port!

    I’ve been reading your old posts about the Basic Process Manipulation Tool Kit and other cool stuff like SRP whitelist bypassing btw. That got me thinking. If SRP checks for CreateProcess and LoadLibrary calls to block stuff, and when you have bypassed this with the BPMTK, has anyone checked if SRP even checks for all the calls we can use to execute code? Lots of exploits use the old 16-bit WinExec() in their shell code instead of CreateProcess. Does SRP even check for that? Anyone know? Would be a pretty easy bypass if it didn’t, lol.

    Comment by ABI — Tuesday 15 September 2009 @ 20:16

  2. This is so cool!!! And I agree with the above poster, sometimes a alco-lock could save you from a lot of trouble πŸ˜‰

    Comment by Jukda — Tuesday 20 October 2009 @ 8:09

  3. i want to calculate gas concentration. can you send the code for that. and also i need source code code for above one.

    Comment by jayaseelan — Tuesday 31 July 2012 @ 7:35

  4. @jayaseelan I’ve no code for that. You’ll have to transform the chart in the datasheet of the sensor to code.

    Comment by Didier Stevens — Tuesday 31 July 2012 @ 15:41

RSS feed for comments on this post. TrackBack URI

Leave a Reply (comments are moderated)

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: