UV Meter & Breathalyzer Keychain - 3D Printed - IoT Blynk

by funelab in Workshop > 3D Printing

18731 Views, 137 Favorites, 0 Comments

UV Meter & Breathalyzer Keychain - 3D Printed - IoT Blynk

3.JPG
Arduino UV Meter & Breathalyzer Keychain - 3D Printed - IoT Blynk
_MG_2479.JPG
_MG_2705.JPG

Imagine the ideal beach trip. The sun is shining, the skies are blue, the water is warm. You and your friends have everything you need to soak up the sun, sand and surf. Well, don't forget the pain-relieving aloe gel in your cooler, for those inevitable sunburns. You're not keeping track of the time since you applied your sunscreen, admit it. You're just gonna burn. Might as well have the aspirin and Lidocaine easily accessible anyway.

You have the fun through the night with a lot of wine with friends and you can't control yourself while driving.

You will need a device that can help you avoid sunburn and drunk too, that's the smart keychain, so you will never forget to bring it. You can do it by yourself with a 3D printer to protect your own health.

This smart keychain will tell you about the sunshine UV (Ultraviolet) index and Alcohol index immediately. Also you can connect it to your smartphone via WiFi to watch these parameters.

This Instructable harnesses the power of 3D printer, Arduino, a UV sensor, a Alcohol breath sensor and simple mathematics to make one nifty gadget sure to boost your outdoor summer fun - and minimize your indoor summer recovery!

I usually use acrylic to make the casing for the previous projects and I've never worked with 3D printer before, so I decided to have a new experience with new materials and techniques - 3D printing. I really had a lot of failure with 3D printing, however I had a lot of experience to make my next project.

Intro: Gallery

_MG_2751.JPG
_MG_2819.JPG
1.JPG
_MG_2810.JPG
_MG_2785.JPG
_MG_2788.JPG
_MG_2813.JPG

Before we get started we are going to need a little bit of motivation, take a look at these pictures and realize what you will be making.

This project could be complete by anyone, just a little electronic and 3D printing skills, you can make yourself a unique IoT keychain. It only takes 3 days to complete the design and to share this project to you, and I hope this project can help you a lot.

Gather Materials

_MG_2453.JPG
_MG_2513.JPG
_MG_2674.JPG

Here is what you need to make your smart keychain:

Electronics Parts:

  • 2 pin button (3pcs)

Tools:

  • 3D printer ( if you dont have one, don't worry, use a 3D print service)
  • Handsaw
  • Drill
  • Drill bits
  • Hot glue and its gun
  • Super glue
  • Soldering iron
  • Tin Solder
  • Wire cutters
  • Paper Tape and Foam Tape
  • Pliers ...

OLED 128x64

_MG_2447.JPG
_MG_2593.JPG
_MG_2483.JPG
_MG_2485.JPG
_MG_2486.JPG

I was impressed the first time to see the small size OLED display. It's so beautiful when displaying text with high contrast. Also, I can find the complete library from Adafruit. This screen is 128x64 pixels, compatible with SPI or I2C interface. I use I2C in this project, because it uses only two wires to communicate, save IO pins for Arduino.

4 pins of the screen outputs include: VCC, GND, SCL, SDA. I use Arduino Uno to run an example from the library of Adafruit. You can find the full tutorial about Monochrome OLED and library in the link.

Start by downloading the library. You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip: Download Adafruit_SSD1306 Library

Rename the uncompressed folder Adafruit_SSD1306 and check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h

Place the Adafruit_SSD1306 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.

Also, you must to Install Adafruit GFX library. You will need to do the same for the Adafurit_GFX library available here Download Adafruit GFX Library

Rename the uncompressed folder Adafruit_GFX and check that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h

Place the Adafruit_GFX library folder your arduinosketchfolder/libraries/ folder like you did with the SSD1306 library

Connect:

OLED ==> Arduino

VCC ==> 5V

GND ==> GND

SCL ==> A5

SDA ==> A4

Test running an example and enjoy the beauty of OLED. It really wonderful.

Note: some OLED screen which you order has I2C addr is 0x3C instead 0x3D, just edit this addr in Adafruit SSD1306 example.

display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)

ESP8260 Wifi Module

_MG_2442.JPG
_MG_2586.JPG
_MG_2588.JPG
esp8266.jpg

IOT - Internet of Things provides the magic, which help stuff link together and fully automated. IoT is the age that you control everything with just your smartphone.

So I want to bring a link to this unique keychain. My idea is you can see the UV index and breathing through the phone screen and displayed as a graph. The data is transmitted through the wifi and wifi I need a very compact wifi module to be placed on keychains.

I've never worked with wifi module before. I think it is very complicated and expensive, but I was wrong. I found ESP8266 module, it is compact, delicate and low cost. What a surprise!

ESP8266 have many different versions, I chose the version ESP-1 because it is the most compact and least expensive. You can view the output pins on the picture.

Wifi module interface through the software uart, in this project is pin D10 and D11. But one problem is the ESP8266 baud rate is 115200 and Arduino maximum baud rate is 9600, so you need to update a new firmware for ESP8266 to bring down baud rate to 9600. I don't detail how to do it here, you can learn in this instruction Esp8266 firmware update and run an example A newbie's guide to setup ESP8266 with Arduino Mega 2560 or Uno

You must edit the PCB of ESP8266 for easy assembly later by removing the header from it and soldering wires on the pins: VCC, GND, RXD, TXD, CH_PD.

NOTE: ESP8266 use VCC is 3.3V, if you connect to 5V will break it. We will make a voltage regulator circuit 5V to 3.3V to power this wifi module.

200mAh 3.7V Lithium Polymer Battery

_MG_2521.JPG
_MG_2520.JPG
_MG_2528.JPG

I choose rechargeable batteries compact as possible, to put the keychain that has enough power to operate for a long time.

Lithium polymer battery is a good choice. Cycle Life(80% Prime Capacity) of this battery is over 500 times. I can easily find a charger circuit for this battery type with low price and simple construction. Battery capacity is 200mAh and the max size is 3.5±0.5 × 20±0.5 × 32±0.5 (Thickness × Width × Height (mm)).

I use 3 batteries in parallel, the total battery capacity is 600mAh, not bad at all. You should note the positive and negative poles of the battery, don't ever confuse them.

Battery voltage when no load is 3.85V, when the load is around 3.7V.

TP-4056 Bettery Charger

_MG_2438.JPG
_MG_2522.JPG
_MG_2515.JPG
_MG_2529.JPG
_MG_2532.JPG

Pretty simple charging circuit is TP4056 Li-Po Charging Module.

This charger is a very small battery charger module. It uses the TP4056 controller and standard configuration is with 1A charge current. It uses a Mini USB for connecting the breakout board to any computer or 'USB wall adapter'. It works with linear charging method. It offers 1000mA charge current by default but it is adjustable from 50mA to 1000mA by soldering a resistor.

Technical Specifications:

  • Method: linear charge 1%
  • Charging current: 1A Adjustable (Through RPROG)
  • Charge Accuracy: 1.5%
  • Input voltage: 4.5V-5.5V
  • Full charge voltage: 4.2V
  • LED indicator: Red is charging,and GREEN is full charged
  • Charging input interface: Mini USB
  • Working temperature: -10℃ to +85℃ Polarity Reversal: NOT ALLOWED
  • Dimensions: 25 * 19 * 10mm

Soldering 3 batteries pack which you have prepared in the previous step to the output of the charging circuit, noting the polarity of the battery. Red to Bat+, Black to Bat-

DC-DC Step-up Module

_MG_2441.JPG
_MG_2534.JPG
_MG_2535.JPG
_MG_2538.JPG
_MG_2543.JPG

To the sensors work, I have 5V power supply. So I use a switching voltage from battery 3.7V to 5V. This circuit works as booster circuit in the backup battery that we typically use to charge the phone. It can operate with input voltages from 0.9V to 5V, output current: 200mA. With input power indicator LED light.

I edited a bit for this module more compact by removing the USB port and soldering couple wire in the output (one for the anode and cathode is another one). Soldering the batteries (or the output of TP4056 ) to the input of this module. You will see a red LED lights indicate the input power and it ready.

UVM30A Sensor Module

_MG_2440.JPG
500px-UV_index.jpg
UV_Sensor index1.jpg
_MG_2509.JPG
_MG_2508.JPG
_MG_2511.JPG
_MG_2547.JPG
_MG_2557.JPG
_MG_2560.JPG

Arduino community is growing fast, and manufacturers also change to meet it. Many of the sensors that seemed only in the factory and it is difficult to buy, but now we can find them easily in the online store. You can make many things with Arduino and you can measure UV index with a compact sensor.

The UV Sensor is used for detecting the intensity of incident ultraviolet(UV) radiation. This form of electromagnetic radiation has shorter wavelengths than visible radiation. This module is based on the sensor UVM-30A, which has a wide spectral range of 200nm-370nm. The module outputs electrical signal which varies with the UV intensity, which gives your suggestion if it is a good idea to beach today.

Technical Specifications:

  • Working voltage: DC 3~5V
  • Curent: 0.06mA(Standard)/0.1mA(Max)
  • Response wavelength: 200~370nm
  • Working temperature: -20~85 Celsius degree

I connect this sensor with Arduino, read analog value and display it on serial monitor. Because in the night and don't have any sunlight, so I'm using an tiny ultraviolet lamp to testing. The output of the sensor is very sensitive to ultraviolet light.

I edited a bit for this module more compact by splitting the sensor PCB pack which includes the sensor and amplifier and 3 pin header (VCC, OUT, GND), it now looks very small.

Grove Alcohol Sensor

_MG_2437.JPG
_MG_2499.JPG
_MG_2502.JPG
_MG_2503.JPG

Grove - Alcohol Sensor is a complete alcohol sensor module for Arduino. It is built with MQ303A semiconductor alcohol sensor. It has good sensitivity and fast response to alcohol. It is suitable for making Breathalyzer. This Grove implements all the necessary circuitry for MQ303A like power conditioning and heater power supply. This sensor outputs a voltage inversely proportional to the alcohol concentration in air.

Technical Specifications:

  • Input Voltage: 5V
  • Working Current: 120mA
  • Detectable Concentration: 20-1000ppm
  • Grove Compatible connector
  • Highly sensitive to alcohol.
  • Fast response and resumes quickly after alcohol exposure.
  • Long life.
  • Compact form factor.

Connect:

  • Arduino UNO ==> Alcohol Sensor
  • 5V ==> VCC
  • GND ==> GND
  • Analog A1 ==> SCL
  • Analog A0 ==> DAT

To know more about this sensor, please refer to Seeed Wiki.

I used Grove Base Shield for Arduino, Connect this module to the A0 port. But you can also connect Gas sensor to Arduino without Base Shield by jumper wires.

Because the size of the sensor board is large, can not fit into the keychain. So I decided to make a PCB where I put the Alcohol and UV sensor onto it. I will show in the next step.

Design PCB

KeyChain_Project_bb.jpg
Schematic.jpg
pcb.jpg

I've downloaded the PCB file of Grove - Alcohol Sensor on Seeed wiki and modified to its smallest possible. Also I add a header to attach the UV sensor on this board.

I design a 5V to 3.3V voltage regulator circuit to power ESP8266 wifi module, on this board has 3 buttons to interact with the Arduino.

The voltage regulator IC is LM1117 3.3V, with max output curent 1A. The modules connected together is shown in Fig.

I attached schematic and layout file. Simply right-click on the attached file, select "save link as" to download the file. You should open this file in Eagle version 6.4 or higher.

Making Printed Circuit Board

_MG_2450.JPG
_MG_2454.JPG
_MG_2455.JPG
_MG_2460.JPG
_MG_2466.JPG
_MG_2468.JPG
_MG_2470.JPG
_MG_2473.JPG
_MG_2475.JPG

I like to make printed circuit boards at home, it saves cost and easy design changes when there is an error in the circuit diagram. But it's not really nice, of course.

Making a PCB circuit boards is simple for anyone who loves electronics. There are many different ways to make printed circuit boards at home. Just search step by step and you will be able to have any printed circuit boards that you like.

After you have finished washing printed circuit boards, you should drill with drill bits 0.8mm.

PCB Soldering

_MG_2548.JPG
_MG_2553.JPG
_MG_2555.JPG
_MG_2562.JPG
_MG_2565.JPG
_MG_2566.JPG

I carefully removed each components on the original alcohol sensor board and solder it to the PCB which I did in the previous step. The components are relatively easy soldering with a simple soldering iron. Just stay calm and be careful. You should also check with a multimeter after soldring.

I also soldering UV sensor on the opposite positions the alcohol sensor, you can see in the picture.

This board has 5 pins output, including: VCC & GND (power), DAT & SCL (alcohol sensor), UV sensor output.

Sensor Board - Test Again

_MG_2569.JPG
_MG_2570.JPG
_MG_2572.JPG

After completion of the soldering circuit, I check again to make sure that the sensor works well before assembling it.

Button Board

_MG_2573.JPG
_MG_2582.JPG
_MG_2584.JPG
_MG_2576.JPG

I soldering 3.3V voltage regulator circuit and check with multimeter. I attached the push button to view installation location but not soldering it to the PCB. I would soldering after placing it in the case of keychain so that it fits in there.

Looking Back at All Modules

_MG_2592.JPG

Wow!!!

I have prepared all the components to assemble a unique keychain. Now the next is making a great shell for it.

3D Case Design by Autodesk 123D Design

3D_4.jpg
3D_1.jpg
3D_2.jpg
3D_3.jpg

This is my first time using 3D printer to build a project. I absolutely don't know about 3D printing at all before, and I have to learn everything. I spent a whole day to choose some 3D design software.

I'm not a professional, of course. So I've to choose a free software and simple, especially to popular and has a support forum. I was wondering Blender and 123D Design.

Blender is an open source software, it is very popular to 3D design. It looks very professional but the software interface looks very complicated and it's not a good choice for a beginner like me.

123D Design was developed by Autodesk, which is famous for AutoCAD, Maya and 3ds Max, ...It is a free product, the software interface is very simple. 123D includes a few simple tools to design, but I think it is more than enough. Perhaps my choice here. I tried looking for a few tutorials related 123D and so surprise with very detailed videos.

I was easily design a few 3D samples, as I said, it is quite easy to use. To design for the keychain shell, I just spent nearly a day, of course, a beginner like me, this is great. I think that those who started with 3D printers, wanted to design yourself a unique thing, so this software is a good choice together.

You can download the latest version of the 123d Design at http://www.123dapp.com/design. A very detailed tutorial about 123D to start entering the 3D world on Youtube. Thank C3 @ Library 21c for the tutorial.

Additionally Autodesk also developed a software support 3D printers - Meshmixer. You can learn more about Meshmixer at http://www.meshmixer.com/

I've attached the files of the shell keychain, you can download and open the 123D Design. I also attach files with STL format in case you use another 3D design software.

3D Printing With UP! Mini

_MG_2624.JPG
_MG_2625.JPG
_MG_2627.JPG
_MG_2629.JPG
_MG_2631.JPG
_MG_2595.JPG
_MG_2596.JPG
_MG_2597.JPG
_MG_2599.JPG
_MG_2600.JPG
_MG_2601.JPG
_MG_2602.JPG
_MG_2603.JPG
_MG_2608.JPG
_MG_2610.JPG
_MG_2612.JPG
_MG_2618.JPG
_MG_2620.JPG
_MG_2621.JPG
_MG_2623.JPG

My first 3D printer is Reprap Prusa i3, I bought it for about $370 on AliExpress (ship fee is included). I started with it and I had a really good experience on 3D printing technology (repeatedly failed). Of course, its print quality in medium ranking and I need to adjust a lot of parameters.

Fortunately, I won the Make It Glow contest and get the Up! Mini printer. I was successful right from the first time.

Up Mini comes with 0.5kg ABS filament which temperatures up to 260 degrees Celsius (also Up filament isn't cheap). This printer is placed in the shell of metal that looks pretty solid, easy to print ABS filament, maximum print size is 120 × 120 × 120 mm (W × D × H). Up Mini can print ABS and PLA, but I like the ABS because it can smooth with acetone. I can print a layer minimum of 0.2mm and 0.4mm maximum. The software is easy to use and you can not change the parameters such as temperature, layers, ...

The temperature is set to ABS is quite high, so I had to install an application that allows me to adjust the temperature and many other parameters to compatible with other cheap filament like Esun. You can find it at SOFTWARE TEMP MOD - ADJUSTABLE LAYER HEIGHTS. Also you can take a look in the UP3D community to learn more about Up printers.

About the shell for the keychain:

  • It is about 3 and a half hours to complete the shell for the keychain.
  • I use two colors are white and silver, white is Up filament and silver is Esun, and both of them are ABS.
  • The temparature for Up filament is 265 and Esun filament is 240 (very low).
  • I used the default support material settings in the software.
  • Layer height 0.2mm.
  • 25% infill.
  • 3 layer for top and bottom and outer shells.
  • Quality settings: Fine.

The files including shells and lids, so print both parts seperately (maybe with two color), and make sure to have good ventilation while printing, otherwise warping may occur, ruining the print.

Don't have a 3D printer (yet)? Find an online 3D printing service on 3D Hubs: A fast and affordable way to get your 3D prints done.

Review the Case

_MG_2638.JPG
_MG_2636.JPG
_MG_2646.JPG
_MG_2643.JPG
_MG_2632.JPG
_MG_2640.JPG
_MG_2642.JPG

Pretty easy to remove the support material from the shell, it looks quite smooth and solid. You can feel the white is more smooth than silver, but that's not true. Because you can't see clearly all the detail in the white material should you feel it smooth. :)

You may also need some tools like a thin knive, sanding paper and more.

Part hangers to attach to keychain is very hard, I was trying to break it, but it doesn't.

I've decided not to surface smooth with acetone because I liked its natural state.

Add the Metal Mesh

_MG_2655.JPG
_MG_2650.JPG
_MG_2656.JPG
_MG_2652.JPG

The highlight of this keychain is metal mesh which I found in a local shop. I really like this detail, it's the combination of different materials, between metal and plastic.

You only need a small piece of 1/2 "x 1" rectangle and you should attach it on shells with hot glue.

Programming Your Arduino

F65AENZHX7OYSO1.jpg
Arduino.jpg
_MG_2682.JPG
_MG_2681.JPG

In this project, I don't use the Adafruit Oled library because its size is too large, and I can't write more programs. Instead I use the U8glib library, it supports OLED displays all series and examples with nice effects. Special thing was this library doesn't take much memory of Arduino which is already very small. You can download U8glib library at GitHub.

HOW TO UPLOAD THOSE SKETCHES TO AN ARDUINO MINI:

I’ve been into Arduino programming lately and looking forward to create a small form factor project. To get code into it you might want to try the following technique. You’ll need an USB Serial Light Adapter or Arduino Uno, Duemillanove or something similar to act as a HOST (detachable Chip!!) . Basically, connect the main Arduino’s 5v, GND, RX,TX (not crossed, just RX to RX and TX to TX) and RESET to the mini. Now for the most important part. DETACH the ATMega chip from the host board (Duemilanove, Uno.. what ever) and start uploading your sketches as you would with the normal arduino. No need to change the Board in the Arudino software. THAT’s IT. Nothing more. Just do it and enjoy.

I was soldering 4 wires to Arduino Pro Mini to fix the program as soon as detect any bugs.

I've attached the program for Arduino pro mini. Just load and run.

Attach the Sensor Module to the Casing

_MG_2670.JPG
_MG_2672.JPG
_MG_2668.JPG
_MG_2676.JPG

I will attach the circuit boards which was prepared earlier on the inside of the shell in several layers. I have to squeeze the layers together for enough space for all.

Use hot glue to fix the sensor board to the keychain shell. You must be skillful in place of the alcohol sensor into the metal mesh which was glued earlier, UV sensors too. Then use foam tape to isolate for the next layer.

Attach the Button to the Casing

_MG_2680.JPG
_MG_2679.JPG

This step I try to locate the push button on the hole in the shell, then solder buttons to the board and fixed it with hot glue.

Screen Mounted on the Casing

_MG_2686.JPG

I marked four positions for mounting screws, which fixed the screen into the shell. This is the hexagonal screws which I obtained from my broken hard drive. You can find the screws in a local store.

Add LED Charging Indicator and Insulated

_MG_2691.JPG
_MG_2693.JPG
_MG_2694.JPG

I use a 5mm RGB LED (common Anode) to indicate battery charge status. On TP4056 module has a green and a red smd LED, red means the battery is charging and green is fully charged battery.

So I soldering anode pins of the RGB LED to BAT+, the output pins for indicate LED of TP4056 is soldering to the green and red pins of RGB LED.

I also use paper tape to isolate the 3.7V-5V module and the TP4056 module. Do the same for ESP8266 module.

Connect All to the Arduino and Run

_MG_2687.JPG
_MG_2698.JPG
_MG_2686.JPG
_MG_2690.JPG

Looking at the circuit diagram which I have presented in step 10, you solder the output of the modules to the Arduino Pro Mini.

Boom... Everything should work fine from now, if not then you need to check the wiring.

Putting All Into Casing

_MG_2714.JPG
_MG_2717.JPG
_MG_2719.JPG

Once you've fixed all on the shell, you must close it with the lid. Place two protruding edges of the lid into the narrow slit of the shell, then rotate clockwise to lock. You can rotate in opposite clockwise to open.

Blynk App for IoT Device

Screenshot_20160628-123108.png
Screenshot_20160627-023359.png
Screenshot_20160701-190334.png
Screenshot_20160627-023430.png
Screenshot_20160627-023520.png

A smart function of this keychain is you can connect to your smartphone as IoT device.

You no longer need to stand in the sun to measure the UV index. Now you can see the UV index and the index of alcohol through a wifi connection. This is thanks to an application called Blynk which successful fundraising on Kickstarter. Blynk is powerful, it's a platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. You can easily build graphic interfaces for all your projects by simply dragging and dropping widgets.

You can download Blynk library for Arduino at GitHub and add to you Arduino library.

Blynk app is completely free, you can learn more at http://www.blynk.cc/. After you download and sign up for a free account, you will get 2000 "energy" to start a new project, when the free "energy" out, you will pay to use. You can also delete previous projects that to regain "energy", this is awesome.

This project is just 1500 "energy" to run. At first you need to start a new project with new name and select Hardware model is Arduino pro mini, then you must get Auth Token code which you will enter into the program on the Arduino. Once the new project has been created, you add the widget box include: a History graph, two of Gauge.

History graph to store data when you connect the keychain with your smartphone. It includes 4 inputs, but you only use two, one for the UV index (select pin Virtual V0) and another for alcohol index (select pin Virtual V1).

Gauge used to let you know the current UV index and alcohol index. You set up a Gauge with input pin is Virtual V0 and values from 0 to 11 for the UV index. Other Gauge has input pin is Virtual V1 and values from 0 to 1023 for the Alcohol index.

You can change the widget box as your way.

In the Arduino program you must to change "Auth Token" to you Auth Token, type your wifi name and password to "SSID" and "password".

Enjoy It!

_MG_2812.JPG
_MG_2745.JPG
_MG_2816.JPG

Hopefully this instruction will help you make a smart keychain to be able to protect your health when strong sunshine (high UV index) and you can control yourself when drunk.