Introduction: Voice Controlled Illumination (Personal Illumination Device)

About: I like to make things.

What is this?

Light up your life a little easier! With the help of a tiny computer, the PID has multiple modes to make use of its bright RGB LED's:

  • Easily find things with Flashlight mode (full brightness)
  • Read comfortably with the Reading mode (a warmer light color)
  • Lazily turn on with Sensor mode (turn on when there's low light, off in bright light, and off when totally dark)
  • Kick back and enjoy some visuals with the Sound visualizer
  • Enjoy a lazy evening or go to sleep with the Candles mode (flickering warm candlight)
  • Wake up / go to sleep color mode

With a connection via bluetooth to your phone and using the Personal Illumination Manager app you can change modes, set brightness, etc. The app also includes voice control!

Step 1: Design and Prototype

The first step is always to conceptualize your design. Draw some sketches, think about what is needed to make it work and how it will fit together. You'll probably have to go through several iterations of your idea, refining it, making compromises, etc. I've included a shot of my notebook showing how my idea progressed.

This is the part where many people get lost. Maybe it seems like its just not going to work, or maybe its just not working how you thought it might. Sometimes as you work through your idea it just becomes something else! Be flexible here and follow through, see where it leads you.

Originally, I envisioned a sleek, small device that folded up into a pocket sized device, and unfolded to a tripod or long stick shape. I quickly realized that this would be hard to make, at least as a prototype and in the time I had to do it. A good designer/engineer/inventor works with what he has available and makes compromises where necessary. After a good deal of thought, my concept evolved to a simpler device (a box) using components that were available to me on short notice.

Step 2: Gather Your Parts

Before we can build anything, we need to gether our parts. Listed are the parts I used for the prototype, but you can certainly select from a wide range of similar parts to get the same result. This is especially true for the Arduino controller that makes it all work. Feel free to use what you have on hand, or what you can easily get.

Bluetooth wireless

The Arduino is paired with the Adafruit Bluefruit LE UART Friend (how's that for a name?) which I was able to get at my local electronics store. There are many similar boards you could buy, some for a lot less cash. Any simple Bluetooth board that acts as serial port over BLE could work. This makes for a very simple hookup, and controlling it all through Bluetooth requires merely sending data through a serial port (the Bluetooth connection to your computer/phone).

The Bluefruit board uses simple Hayes AT style commands (yes, just like you used to use back in the old days with your modem...) to control the board (for instance, to change the Bluetooth device name) which other Bluetooth boards don't have. Its also a Bluetooth Low Energy (BLE) board which is different than regular Bluetooth. For these reasons, the Arduino code and the mobile application would need to be modified if another style board was used.

Controller

I looked at a lot of the available options for the controller, and there are some really cool and really tiny little Arduino's (and others, like ESP8266) out there that would have made the ultimate result much more compact. However, my local stores didn't carry them and there wasn't time to mail order. Also, I wanted to keep things as simple as possible.

I planned on using a pretty standard Arduino Pro Mini. This particular board does not have a built in USB for programming it, like for instance a standard Arduino Uno or Nano. Its good for permanent builds because its a bit smaller. However, you do need to program it, so you need to use the FTDI connector with a USB to FTDI board (FTDI is essentially just a serial port).

Sensors

Like the Arduino, there are a lot of different variations of these basic sensors but they all pretty much work the same. I found some sensors from OSEPP, the LDR sensor and the Microphone sensor.

Light

Originally I planned on using 2 NeoPixel sticks with 8 LED's each, however my local store didn't have any in stock. Because of this I had to find a backup solution, which resulted in changing everything...

Adafruit Circuit Playground

I stumbled across this really cool little board that has almost everything needed to implement the PID built in. Its an Arduino board with the same type of processor as most Arduinos but packs in sound, light, and temperature sensors, as well as a motion sensor; but most importantly, it has 10 NeoPixels on it. Now, these are mini pixels so they are not as bright, and they are arranged in a circle; but they are still plenty bright enough! And you can get one of these for just $20. Paired with the bluetooth board and its almost too easy.

A Box

You can use any clear box you can find, but I used an Amac box with the dimensions 2 5/16" x 3 1/16" which was just the right size for the height of the battery and the diameter of the Circuit Playground.

Complete parts list

I've included links to where you can get these parts, even though some of the parts I used were from my own supply, and I repurposed a USB battery pack.

You will also need a soldering iron for the headers on the UART board, some drill bits and an X-Acto for cutting into the box.

Step 3: Wiring Diagram

The Fritzing image (original Fritzing file also attached) shows the wiring. With the Circuit Playground, the wiring is pretty simple. All the sensors and LEDs are already connected.

The battery charger is not the same as what I used, which was an inexpensive USB battery bank using a Li-Ion battery and connecting through the USB instead of the battery connector. If you buy a charger board the wiring should be pretty clear. The battery bank I used required me to solder a couple wires to the back of the USB port (actually using a USB cable was too bulky).

The hookup is pretty straightforward:

  • Bluefruit TX connects to Arduino RX
  • Bluefruit RX connects to Arduino TX
  • Bluefruit CTS connects to ground
  • Charger board + connects to Bluefruit VIN and to VBAT on Arduino
  • Charger board - connects to the middle of the switch
  • Bluefruit ground (gnd) and Arduino ground connect to the side of the switch
  • Finally, the battery + and - connect appropriately to the charger board

Step 4: Battery and Charger

I 'upcycled' a portable battery bank that you can buy almost anywhere for just a few dollars. These little banks almost always have the same kind of standard Li-Ion 3.7 volt batteries inside. They are reliable and easy to work with (Li-Poly battery packs can be easily damaged). We really need a minimum of about 5v to power the Arduino and the LED's for decent brightness, so these little battery backs contain DC-DC converters to make that 3.7v into 5v, in addition to the charging circuit.


Because I didn't want to try and pack in a full USB cable and connector, I simply soldered two wires onto the back of the USB port. There are four wires and you want to connect to the outermost two wires. If you are looking into the end of the USB connector, the right side is the ground and left side is the positive. Alternatively, you can just buy the battery and a charger as listed in the parts list, which is functionally the same and easier to hook up.

Step 5: Breadboard

I used a tiny breadboard for the Bluefruit module, and the switch. The Circuit Playground is attached on the end with a little double sided tape. The breadboard also comes with double sided foam tape, which we will use to attach it to the inside of the box. This provides support for the Circuit Playground (the battery will support the other side as its just the right height).

The bread board has enough room on it to support a couple sensors for future enhancements, or any other changes we might want to make.

The switch is a breadboard friendly switch with a 3 pin right angle header soldered to it, so it can mount sideways on the breadboard. This allows it to extend through a hole on the side.

Step 6: Controller Software

For anything interesting to happen, we have to program the controller and tell it what to do.

To actually compile and run the code on an Arduino, you can't beat create.arduino.cc! Yu have to install a plugin first, but this is much easier than installing the full Arduino editor. Plus your programs are stored online and can be accessed anywhere. The code for this instructable is thus available here. Once you have the plugin installed, you can program the Circuit Playground by simply connecting it to the computer with a standard USB cable.

Setting up the code takes a few steps (this could be simplified..). The first time you load the code, you need to uncomment a block of code at line 112:

<p>/**<br> * Uncomment the code below the first time you load, so that it can set the name of the bluetooth device
 * 
 
  while (! ble.isConnected()) {
      delay(500);
  }</p><p>  //** change the name of our bluetooth device. We dont have to do this everytime because its stored, but this is easy
  ble.sendCommandCheckOK("AT+GAPDEVNAME=Personal Illumination Device");
 */</p>

Change it to this:

<p>/**<br> * Uncomment the code below the first time you load, so that it can set the name of the bluetooth device
 * /
 
  while (! ble.isConnected()) {
      delay(500);
  }</p><p>  //** change the name of our bluetooth device. We dont have to do this everytime because its stored, but this is easy
  ble.sendCommandCheckOK("AT+GAPDEVNAME=Personal Illumination Device");
 </p>

Then compile and load the code onto your Arduino. Turn the PID off and then on again, then, use the Bluefruit LE app to locate your device and connect to it using the UART mode. This will then cause the Arduino to rename itself. At this point you can send commands to your PID to see how it works.

Once this is done, you can comment out the code again and then reload it. Your PID is now ready to use.

Step 7: Put It in a Box

Amac Box

Who doesn't love Amac boxes? You know the ones. They come in lots of sizes and colors and they have flush lids and they're completely 'square' (no slopes or ridges or anything) and they can stack nicely. I love them. My grandmother always had these in her home full of interesting things and I would explore them for materials I could use. My kids spotted this cool box I made and their curiosity exploded. What is that? Its glowing! And the cycle repeats...

So it was a natural thing to put this project into an Amac box. Since we are generating light in any color, I had to go with a clear box, even though the colored ones are just so.. beautiful! In retrospect, I could have gotten one clear box and one colored box and used the clear lid with the colored bottom.

The 2 5/16" x 3 1/16" size "flush lid" box was the perfect size. The height allowed for the battery to stand up and double as support for the Circuit Playground, and the width x depth of the box was just comfortably big enough for the diameter of the Playground board. The lid also is short, about a quarter inch, so the board can be right up on top.

Make some holes

I drilled two small holes with a 5/8" drill to create a slot for the charger USB to go through, then used an x-acto knife to cut the bridge between them out and to smooth the holes. I did the same thing for the power switch and again for the USB on the Circuit Playground at the top so I could be reprogrammed without removing it. I did NOT cut a hole in the lid though, so the lid covers this hole when in operation.

Step 8: Test

Before you try to place it all into the box make sure its working. When you turn it on, you should see a little green LED on the Circuit Playground, and a blinking red LED on the Bluefruit. Using the Bluefruit LE Connect app, you should be able to connect to your PID and send it some commands:

Flashlight mode at brightness 60 (it goes from 0 to 255):

M1 60

I've had it sitting on my desk at work for 2 days now on a single charge, in organ/visualizer mode mostly, and it hasn't drained the battery yet. In candle mode I've had it running all night while sleeping.

Step 9: Personal Light Manager App

It is far beyond the scope of this instructable to detail how to build a mobile app to control this device. There are many ways to do it. I have built a simple app using Ionic framework (and prototyped using Ionic Creator) which you can use. Provided is the apk to install on your Android phone, but you can download and build the app yourself for Apple or Android. The app is available on Google Play. The whole source code is available on GitHub if you want to study it or compile your own version (and maybe contribute to the code yourself.. I would love any submissions!).

The app is very simple, it works by sending simple text data through the Bluetooth connection as a "virtual" serial port. The PID receives this data and acts on it. There's nothing fancy here (beyond what Bluetooth does for us, behind the scenes), so we have to invent a "language" or "protocol" so the app can communicate to the PID.

The app uses the Ionic Native BLE library to scan for available devices, and then connect to the first one it finds with the name "Personal Illumination Device". In theory, it could connect and control multiple devices but I did not flesh out the code to do so (and I've only built one device).

The control protocol is 'M' for mode, followed by a number, and then depending on the mode, additional data. So for example, flashlight mode is:

M1 50

The '50' is the brightness, from 0 to 255.

Other modes are as follows:

Reading mode:

M2 50

Detect / Sense mode:

M3

Sleep and Wake:

M4S

Turns on the nightlight color

M4O

Turns off the light

M4W

Turns on the waking light color

Organ / Visualizer mode:

M6

Candle mode:

M7

Attachments

Step 10: Future Features

The more I think about it, the more ideas come to mind. I plan to continue this design and add more features:

  • Motion detect with a PIR module
  • Show temperature since we already have a sensor for it
  • Countdown mode. Reset on tipping device over?
  • Turn it on and off when your phone is close or not.

I would welcome any code submissions...

Step 11: Epilogue

On completion of the device, after my older son and daughter had at it for a bit, I showed it to my wife and baby. Shortly after demoing it, she said, "you know, you're not getting this back, right?" and I said "by who?" knowing that my son already wanted it. So she liked it. And the baby pretty much snatched it right out of her hands and starting talking into it, and tapping it, to make the lights (it was in color organ mode). Here's a cute video of her playing with it. I may have to make a few more...

Need I say more?