IoT Breathalyzer & Car Key Usage System for Recovering Alcoholics

by s_morrow in Circuits > Arduino

302 Views, 2 Favorites, 0 Comments

IoT Breathalyzer & Car Key Usage System for Recovering Alcoholics

IMG_3223 (1).jpeg

This Breathalyzer is a home tool for recovering alcoholics or people that enjoy drinking. It does several things:

  1. Requires that the breathalyzer be used before picking up your car keys. If you don't use it AND pick up your keys then it will alert your friends that you are trying to drive while drunk.
  2. After using the breathalyzer and calculating your Blood Alcohol level, it does several operations:
    1. It alerts you on the Blynk app of your Blood Alcohol level and with an Integromat push.
    2. It stores your Blood alcohol reading in google sheets for your own use and tracking at a later time. This allows you to keep track of how long you have been sober.
    3. If you are over the legal limit, it alerts your designated AA sponsor.

For building the IoT Breathalyzer & Driving helper for Alcoholics with the MQ3 gas sensor. Here is what you will need:

Supplies

  1. Arduino Circut Playground CPX board with preconnected ESP8266 board x1
  2. MQ3 Gas Sensor with attack PCB board x1 - you can get the sensor here and the board here
  3. Aligator clips x5
  4. Soldering Equipment
  5. Resistor 200k ohms x1 - you can get it here
  6. Some basic copper wiring - we got ours from an old mouse
  7. Smartphone
  8. Integromat account for the Scenario
  9. Integromat App on your friends/sponsors phone
    1. Google Play
    2. Apple App Store
  10. Blynk App
    1. Google Play
    2. Apple App Store
  11. Your keys
  12. An Alcohol problem

Preparing the MQ3 Gas Sensor

WhatsApp Image 2021-02-25 at 8.39.39 AM.jpeg
product_402_953_200x200.jpg
IMG_4597.jpeg
IMG_4596.jpeg
IMG_4598.jpeg
Video Soldering parts wires and resistor to the MQ3 gas sensor
IMG_3220.jpeg
IMG_3219.jpeg
IMG_3221.jpeg

To prepare the gas sensor, take your MQ3 with a pre-connected PCB board, resistor, and your 3 simple wires. Now that you have them, solder the resistor to the appropriate spots and the 3 simple wires to the 3 holes on the edge, one is for ground, the next is VCC, and then the out. Take a look at the picture of the board and detailed there are the exact spots to connect each wire.

Note: the MQ3 gas sensor requires a 5V but the output voltage of the CPX is 3.3 so it's usable in this case but requires a significantly longer preheat time.

Here is how it should look at the end of it!

Set Up the Integromat Scenario

Screen Shot 2021-02-27 at 14.25.38.png
Screen Shot 2021-02-25 at 20.30.33.png

The Integromat scenario handles the notifications to your AA sponsor and saving your BAC readings to the google sheets. So let's get started!

  1. Log into your Integromat account and create yourself a new scenario. You will need to use the Webhook, Apple iOS or Android, Google sheets, and the Router and Incrementor modules.
  2. Set up the web hook so that the URL resembles the following:
    {webhook_base_url}?title=/pin[0]/&alcoholLevel=/pin[1]/&bodyMessage=/pin[2]/&testTaken=/pin[3]/
    and save the full webhook address for later.
  3. Now connect all of the modules as shown in the picture above.
  4. Open your google sheets and set up the sheet with the following columns:
    1. Date
    2. Time
    3. Blood Alcohol Reading
  5. Go to the Sheets Module as set it up according to the picture added.
  6. Remember, to set up the notifications to go to your AA sponsor's phone. They need the Integromat app on their phone for it to work.

Set Up the Blynk App Project

IMG_4619 (1).jpeg
IMG_4625.jpeg
IMG_4624.jpeg
IMG_4623.jpeg

The Blynk app allows us to interface between the CPX and Integromat and gives us a visual aid for the user of the Breathalyzer.

  1. Download the Blynk up, set it up open a new project
  2. Save the Auth token for use later
  3. Add the following to your project:
    • Terminal and set it to use pin V1
    • Gauge and set it to use V5 and to the range to be from 0 to 1023
    • Webhook:
      • Take the webhook URL from the Integromat scenario and add the following suffix to it:
        • ?title=/pin[0]/&alcoholLevel=/pin[1]/&bodyMessage=/pin[2]/&testTaken=/pin[3]/

      • Set the URL address to the URL from the previous step
      • Set its output pin to V0
      • Method to POST
      • Content type to application/json

Once you have all of these steps done, set the device of the project to be Arduino MKR1000 (WiFi). Now, grab the Auth token for the Blynk app and send it to yourself so you can open it on your computer. Congratulations! You have just completed another step towards completing the project.

Writing the Code for the CPX:

Screen Shot 2021-02-27 at 14.16.58.png
Screen Shot 2021-02-27 at 14.07.18.png
Screen Shot 2021-02-27 at 14.08.53.png

Now, I'm not gonna give you all of the code here as we want you to try for yourself and learn how its done. But I will give in-depth explanations of how exactly to do what needs to be done.

Here are the cases that you need to deal with:

  1. Keys being pick up and recognizing if the breathalyzer was used already
  2. Only starting the program when the CPX senses that someone is approaching it. Hint: use the Proximity library and the IR sensors
  3. Running the Breathalyzer on command and doing the BAC calculation
  4. Sending the resulting BAC score and proper messages to the Blynk App

Putting It All Together!

IMG_3222 (1).jpeg
E6931916-0D43-449D-AF72-84B49330D877.JPG

Now that you have the CPX code loaded, the Blynk app all set up and ready to go, and the Integromat scenario live, you can now connect all of the pieces together.

  1. Take 2 alligator pins, connect one both to your car key and the other ends to the CPX, one to ground pin and the other to pin A2.
  2. Take 3 alligator pins and connect them to the 3 wires which you soldered onto the MQ3 gas sensor. Ground pin to the ground wire, Out pin to the Out wire, and A0 to the middle wire.
  3. Upload the CPX code to your CPX.
  4. Congratulations! You have successfully built a home breathalyzer and car key notification system.

Seeing It in Action

IMG_3225.jpeg
E6931916-0D43-449D-AF72-84B49330D877.jpeg

Now that you have built the thing, let's make sure it works!

First, first up the CPX and let your MQ3 sensor start to warm up. It needs at least 20 minutes to warm up to get logical readings but preferably 24-48 hours of warming up to get the most accurate readings.

Once the sensor is all warmed up, grab some local grain (non-drinkable) alcohol, a paper towel. Put some of the alcohol onto the paper and, while getting close to the CPX, hold the paper towel close to the sensor and watch as it registers the alcohol on the paper. You should receive a message on the Blynk app and on notification from the scenario. You can also now go and look at the google sheets that keep track of your alcohol readings and see the calculating BAC there too.

So that's it, good luck and stay safe out there!

Here is a video of how it should work.

Thanks for tuning in and following this instructable, comment if there is anything we should add or fix.

*Note that the results of the MQ3 gas sensor will vary per how long you give it to warm up, the strength of the connection of the clips, and how you calibrate it to your system with its threshold and the like.