Introduction: Talking IBreathe Breathalyzer With Bluetooth IOS App and IoT

Picture of Talking IBreathe Breathalyzer With Bluetooth IOS App and IoT

This is a tale of boozy thoughts..

Drinking beer, wondering how much alcohol i have actually drunk, wouldn't it be nice to be able to check? and then ping the result to my smartphone? then to the cloud? and the document it as a lovely table to see alcohol intake through time? Well here is the result!

The iBreathe Breathalyzer!

Step 1: What Is Hexiwear?

Step 2: First Steps

For this project you will need:

  • 1 x NXP Hexiware
  • 1 x Hexiware Docking Station
  • 1 x Alcohol Click Board
  • 3 x 10K Resistor
  • Sharp Knife
  • Soldering iron and solder
  • Access to a 3D printer (not necessary, but really finishes the design nicely!)
  • A www.wolksense.com Login (more on this later)
  • An www.mbed.com Login (also more on this later)
  • Xcode (for the custom iPhone App)

Step 3: Things Used in This Preoject

Hardware components:

NXP Hexiwear×1

MikroElektronika Hexiware Docking Station×1

MikroElektronika Alcohol Click Board×1

Super Glue×1

M3 countersink Screw×3

Resistor 10k ohm×3

Polymaker Polywood PLA×1

Polymaker PolyPlus PLA (White)×1

MikroElektronika Text to Speech Click Board×1

Mouser 1" 8ohm speaker×1

Mouser 3.5mm Headphone Jack×1

Software apps and online services:

ARM mBed OS 5

Apple Xcode

Autodesk Fusion 360

Hand tools and fabrication machines:

3D Printer (generic)

Soldering iron (generic)

Step 4: Beginning

Take your brand new Hexiware dev kit and have a play! it's really a one stop shop device that can do tons already, such a great development platform as a first foray in embedded design.

Plug your Hexiware onto the docking station and connect the USB cable to your computer. It will show as an attached drive called DAPLINK. This is where you will simply drag and drop your compiled *.BIN files when you have finished your program. Once dropped in the DAPLINK drive, the Hexiware will automatically load the new firmware.. how jolly easy!

Step 5: ARM MBed OS 5

I chose to use mBed OS5 as my platform for developing for the Hexiware for 2 main reasons:

1. Browser based SDK - I could code from any of my computers without the fear of my desktop SDK's not being configured exactly the same.

2. Really easy to get going.. seriously I was able to run my first program on my Hexiware within 5 minutes of signing up at www.mBed.com.

So without further ado, head on over to www.mBed.com. and sign up for your free mBed account.

Once you have signed up the next step is to go to the dedicated Hexiware page. Here you will find all the information you need to get started compiling your first program

Head on over to the Hexiware Code Repository, here you will find a ton of examples that will quickly get you started programming!

To begin with I chose the Hexi_Blinky_Example , this is a nice simple LED blinking program and a great place to get started. From this page, click on "Import into Compiler" and this will fork your very own copy of the program to do with as you will... fun.

#include "mbed.h"

DigitalOut myled(LED1);

int main() {

while(1) {

myled = 1;

wait(0.2);

myled = 0;

wait(0.2);

}

As you can see it's super simple with very little set up, the most important thing is to remember to include the mbed.h header file. This is essentially the mBed OS you'll be running your program on.

Hit compile! the *.BIN will download, drag and drop this onto the DAPLINK drive (the drive your Hexiware is shown as) once it has copied across, hit the reset button and boom! you have a flashing LED!

Step 6: The Idea

Picture of The Idea

Okey dokey, now that we're experts in mBed OS 5 it's time to start creating something.. something we can use!

I wanted to create a Breathalyzer that could tell me how much I had drunk, whether or not I was safe to drive, pinging the values to my Phone and then subsequently the cloud.

First things first, the hardware. We already have our Hexiware and Docking Station joined at the hip, so all we need to to attach our Alcohol Click Board right?

Well.. not quite. It turns our the Alcohol Click Board runs at 5V levels, and my little Hexiware's analog input is 3.3V. so it's time to do a little PCB modification to get things playing nicely with each other.

We need to add a voltage divider on the output pin of the Click Board. This where the 3 x 10K resistors come in.

You will need to cut the tracks as shown in the pictures, and then solder the resistors in place.

Now we're ready to go! Plug in your modified click board. and load up my code from the mBed Code Repository , import it to your compiler. Hit compile, drag and drop the *.BIN to your DAPLINK drive and away you go!

Step 7: Assembly of the Docking Station

Step 8: Function Screenshots

Picture of Function Screenshots

Step 9: Test Procedure

Picture of Test Procedure

NOTE: I don't have access to proper calibration equipment so this is just a showcase project, I will not be held responsible for any loss of Driving Licenses, underwear, teeth or dignity

Step 10: Technical Challenges Faced in Development

So there were a few things that were not immediately obvious how to do, but after some digging, it all became clear .

1. Using Bitmap images with the Hexiware on-board OLED display. This is actually fairly straight forward. The OLED is a 96px x 96px screen, so this needs to be taken in to account when creating your images. Using Photoshop / GiMP you need to save you image as a BMP file, you will need to click advanced settings and select the BMP type as 16bppRgb565 . Make sure there are no spaces in the file name. Next step is down download the Hexiware Utilitythat will convert your BMP files to *.c and *.h files that can be imported into the mBed compiler.

You can process multiple images at the same time using this utility, and the cool thing is it pops them all in the same *.c and corresponding *.h files.

Make a note of where you saved them and import them into you mBed compiler as libraries. Add the *.h file into your #includes and you're ready to start pointing pointers and showing some cool pictures!

Here's the mBed sample code showing how the image is referenced and send to the OLED for showing. (the full version of this code is available on the mBed Hexiware Code Repository)


Have a play around with this and all will become clear!

2. Sending my iBreathe data over Bluetooth to the Hexiware iOS App. OK this was a little bit hacky, but none the less, fun! So to cut a long story short all the UUID's for the KW40Z were preassigned to work with all the built in sensors in the Hexiware. So i pinched the Pressure sensors one and used that to transmit the data via bluetooth to the Stock Hexiware iOS app.

3. Could i create my own iBreathe iOS app to received the data? Yes! yes i could! the Hexiware App is open-source, so i was able to add my iBreathe Sensor into it with a fun logo. If you know swift, then it's not too much trauma, you just need to use a UUID for one of the unused sensors for the iBreathe Data stream. The Stock Hexiware App can be downloaded and modified from here.

My version of the app can be downloaded from the code section below. Sadly i was unable to get Wolksense to see my splendid new iBreathe logo, so for the purposes of logging, i send the data to the Pressure Sensor, and log that.

4. Text To Speech Click Board - Well, it was always my intention for this project to have a voice, but seen as there hadn't been an mBed OS implimentation on the Text To Speech Click, i'd decided to get the bulk of the project working before i attempted to get the speech working. Well... after 1 week of late nights and frustration, i managed to port the code over to work for this project. Now... currently it is NOT a library, but a pretty sizeable main.cpp file, my intention is to make a library at some point so everyone can use it trouble free. For now, copy and paste is you friend :) i learnt so much from this process, like SPI bus interfaces, how important delay timings are and how jolly satisfying when something suddenly springs to life :) I have commented code fairly well, so hopefully it makes sense. if there is anything you're unsure about, hit me up! after all this work i feel like i know it back to front :)

Step 11: Wolksense

Picture of Wolksense

As stated i didn't get this working perfectly, but it's a nice little work around. Wolksense is a great site that takes the cloud data you pass to it and logs it.

First of all you will need to sign up here Once you have done that you can use the Hexiware App (the stock one or my version works just as well) to register your Hexiware device. The sensors that are available will show on your screen and the data will be transmitted via your phones data connection to the Wolksense Cloud, Using the Wolksense App (on your phone) you are able to chose which sensors you would like shown, i turned off everything other than Pressure. Named it iBreathe Breathalyzer, and hit save. I was now logging the alcohol levels by all but name. The code for the iBreathe Breathalyzer transmits to both iBreathe and Pressure. Meaning on your phone you will see the Beer and pressure gauge showing the same value. This is a work around and should this ever go into production would of course be fixed. One thing is for sure, Wolksense is a jolly pretty place to store all your data points!

Step 12: Autodesk Fusion360

Picture of Autodesk Fusion360

So as the final part of this project, i decided to design and 3D print an enclosure. I wanted it to be fun and practical and this is what i came up with!

It's basically a big beer! the limiting factor was the fact the Docking station is able to house 3 click boards, when i only needed 1. so the size was dictated by that.
The enclosure is 3D printed, and assembled with a combination of super glue and M3 screws. To power the iBreathe, I used a USB power bar which is housed in the beers head.

I've printed the top cover from PolyMaker Polywood PLA, the head and back cover were printed with Polymaker PLA+. I can't recommend Polymaker filament enough, it's really amazing stuff!


Printer Settings:

Heatbed 58C

Hot end 200C

20% in fill

70mm/s Print speed

Use Supports

Step 13: First Demo

Step 14: Final Demo With Added Speech Engine

So, for the last week i've been working on an addition to the iBreathe Breathalyzer. He now has a voice and gives you commands on how to use it! it will then politely tell you how drunk you are.

Using the Text To Speech click board, i have given him a voice, and to my knowledge this is the first time the Text To Speech click board has been implemented on mBed OS! It was over a week of porting and debugging and now the results can be seen in this video!

The code can be found at the bottom of this page (along with the original non speaking version) and can be easily adapted for any project using mBed OS. I'm sorry it's in one big main file, but i ran out of time to chop it up into smaller bytes (pun intended)

.
For more information on the Text To Speech Click Board click here!

Step 15: All the Code

Step 16: STL Files for 3D Print

Comments

Swansong (author)2017-09-06

That's an awesome project! Neat design and great instructable :)

daveyclk (author)Swansong2017-09-10

Thank you!

About This Instructable

1,091views

13favorites

License:

Bio: I'm a 3D designer and Maker with over 10 years 3D design experience. I've been 3D printing / Making since 2013. Love Star Wars ... More »
More by daveyclk:$10 iPhoneX Wireless Charging StandWalabot FX - Guitar Effect ControlHolocron Lamp for the Discerning Jedi
Add instructable to: