Introduction: UV Meter & Breathalyzer Keychain - 3D Printed - IoT Blynk
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.
Step 1: Intro: Gallery
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.
Step 2: Gather Materials
Here is what you need to make your smart keychain:
- Arduino Pro Mini 328 - 5V/16MHz
- Arduino Uno or FTDI (to programming for Arduino pro mini) - I used Uno in this project.
- Monochrome 0.96" 128x64 OLED graphic display
- DC-DC 0.9V-5V to 5V step-up module
- TP4056 Lithium battery charger 1A
- ESP8266 ESP-1 Wifi module
- Grove Alcohol Sensor
- UVM30A - UV sensor module
- PCB sheet 2"x2"
- RGB Leds (1pcs)
- 200mA Li-Ion Battery (3pcs)
- Electrical wire ...
- 2 pin button (3pcs)
- 3D printer ( if you dont have one, don't worry, use a 3D print service)
- Drill bits
- Hot glue and its gun
- Super glue
- Soldering iron
- Tin Solder
- Wire cutters
- Paper Tape and Foam Tape
- Pliers ...
Step 3: OLED 128x64
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
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)
Step 4: ESP8260 Wifi Module
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.
Step 5: 200mAh 3.7V Lithium Polymer Battery
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.
Step 6: TP-4056 Bettery Charger
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.
- 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-
Step 7: DC-DC Step-up Module
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.
Step 8: UVM30A Sensor Module
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.
- 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.
Step 9: Grove Alcohol Sensor
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.
- 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.
- 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.
Step 10: Design PCB
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.
Step 11: Making Printed Circuit Board
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.
Step 12: PCB Soldering
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.
Step 13: Sensor Board - Test Again
After completion of the soldering circuit, I check again to make sure that the sensor works well before assembling it.
Step 14: Button Board
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.
Step 15: Looking Back at All Modules
I have prepared all the components to assemble a unique keychain. Now the next is making a great shell for it.
Step 16: 3D Case Design by Autodesk 123D Design
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.
Step 17: 3D Printing With UP! Mini
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.
Step 18: Review the Case
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.
Step 19: Add the Metal Mesh
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.
Step 20: Programming Your Arduino
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 U8gliblibrary, 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.
Step 21: Attach the Sensor Module to the Casing
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.
Step 22: Attach the Button to the Casing
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.
Step 23: Screen Mounted on the Casing
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.
Step 24: Add LED Charging Indicator and Insulated
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.
Step 25: Connect All to the Arduino and Run
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.
Step 26: Putting All Into Casing
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.
Step 27: Blynk App for IoT Device
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".
Step 28: Enjoy It!
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.
We have a be nice policy.
Please be positive and constructive.