Introduction: Heart Rate Party Pendant
My friends were talking over brunch once day about how cool (and how terrifying) it would be if a person you are chatting with (maybe at a party or on a date) could actually see when your pulse quickens, providing a window into your feelings of excitement or nervousness.
Seemed like a fun and ridiculous idea, so i made the (prototype) Heart Rate Party Pendant, a pendant that shows your live heart rate! Or, just play some nice mesmerizing colors (video here)
Before starting you will need:
- 3d printer (or printing service)
- soldering iron
- wire stripper
- glue gun
- 50 WS2812 LEDs (Something like these)
- Pulse Sensor (This is the model, but you can probably find it much cheaper on ebay)
- Trinket Pro (I went 3v to optimize battery life. Probably any small arduino will do, though i couldn't quit fit it all on an attiny85 based device like the normal adafruit trinket)
- FTDI friend (not needed if you are not using a trinket pro)
- Lipo battery
- JST Connector
- Solid core hookup wire
- potentiometer (This is to control brightness. The resistance value doesn't really matter, just needs to be small and preferably easy to turn by hand like this )
3d printing Filament (just about anything will do for the case, but for the lense you need something transparent like natural PLA or PETG)
Some previous experience with arduinos and soldering is also highly suggested, though for a "first project" this isn't the most complicated.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Print the Case and Diffuser
You can get the stls for 3d printing from thingiverse, or from github. The "Case" and "Lid" are pretty straightforward. I printed with 3 shells and 15% infill, with black ABS, but you can use whatever settings or color you prefer.
However the "Lense" is specially designed to diffuse the light from the LEDs, so it needs special slicing options and materials. You need to use a transparent filament like Natural PLA or PETG (i used PETG), and print with 2 shells, 4 bottom layers, 3 top layers, and 0% infill to achieve a nice diffraction. I designed the "lense" to have internal structure that should spread the light and provide support, but using an infill will make look much less pretty when the light shines through.
Step 2: Wire Up Your LEDs
Now for the long, "fun" part. Take your WS2812 LEDs and lay them into the slots in the back of the lens, taking care to make sure they are oriented the same way (the "in" columns should all be on the same side). Start off laying out and soldering just one row at a time.
Take some solid core wire, measure it out so it spans the length of the row and strip off all the insulation. You'll need two per row, one becomes the v3 power bus and one becomes the ground bus. Lay the first wire across the top row (which is the "ground" row in my example), and start soldering the ground pads to the wire for each LED. Try not to have the LEDs move from their indents; once they are soldered in, they ain't movin'. The LEDs have an "in" and "out" pad for data, power, and ground, but for power and ground you only have to do one pad per LED each (i just did the "in" column). Nothing bad will happen if you do both in and out, but skipping one will save you a ton of time.
Next solder in the data lines. These have to be done in order, for each LED, with the "D out" connecting to the "D in" of the next pixel in the series. I cut a bunch of 3/4 inch wires, stripped their insulation, and used tweezers to hold them in place.
Take your completed strip out and test it to make sure you dont have any shorts. (More details in setting up the arduino for testing in the next step). The LEDs are pretty resilient so if you have a short you can just resolder any problem connections and it should be good.
Repeat for the all the rows. Make sure the layout of the LEDs for every other row is flipped (for example, the even rows have the "D in" on the left side and the odd rows are rotated 180 to have it on the right). This will save you from having to snake a long data line between the rows.
Then connect all the rows together. Again make sure the rows are seated correctly in the slots before soldering them. Also since every other row is upside down, take care to connecting the right ground to ground and power to power.
Once you are sure your array is good to go, glue it onto your lense with a glue gun. You can be pretty generous with the glue here, it helps prevent movement that can break your array. Then slip your lense into your case and add another dollop of hot glue to bind them together. Now you are ready to add in the arduino and other components!
Step 3: Program the Arduino
Now that we have our LED Strips, let's program our arduino. Before we complicate things by adding in all our sensors and switches, let's start with just a simple strand test program to make sure our LED array is working as expected, and get our upload process ironed out.
Open up your arduino editor. If you are using the adafruit trinket pro, you will have to first download the board definitions. Luckily adafruit keeps pretty nice instructions on how to do that. You will also need to install the neopixel library. Once setup, go to File->Examples->Adafruit Neopixel->strandtest.
Next you need to tell the arduino IDE how to program the Trinket Pro. I've had problems uploading using the USB interface and found that i had to use the FTDI Friend to program it. Connect it to FTDI header on the trinket pro (you may have to solder some pins in there, which come with the FTDI Friend packet). In arduino IDE, go to Tools->boards and select the "pro Trinket 3V/12MHz (FTDI)" option. Then go to Tools-> Programmer and select "USBTinyISP". Hit upload (you may have to hit the reset button before uploading).
Once you've finished a row, test out your strips. My tester set up was just the trinket on a breadboard, with some wire with alligator clips soldered on, which i clipped on to power, ground, and data lines of my strip (note it is best to connect ground first if the power is on, so you dont hurt your LEDs).
Once you've tested all the strands and soldered the full array together, you can get upload out Heart Pendant source . You can get the most recent source code from Github, under the "arduino" folder. Pull down the full "ledHeart" folder onto your desktop and open it up in your arduino.
There isn't too much here you need to worry about in the source if you dont want to modify the project. The most interesting things would probably be the "#define" block at the top of ledHeart.ino that define which pins hook up to what components. You can change these if you want to lay out your arduino board a little differently.
Once uploaded we can wire everything together.
Step 4: Wire It Up
Now time to wire everything up to our arduino. You can use the schematic as a reference.
First, solder on the JST connector to the arduino board (its labled for you). This is where the battery goes that powers everything).
Next, cut 3 wires to hook your LED array to your arduino. Make sure you connect the data line to the first "D in" in the array. The power and ground can connect anywhere (on their respective buses). Once these are connected, lay down a layer of masking tape across the backs of your LEDs. This will prevent any accidental shorts when you jam the arduino into the cramped space. Then wire the array to the arduino (reference the schematic).
Now comes the pulse sensor. The sensor works by shining a light on your skin and measuring how dark it is. As your heart contracts, the capillaries in your skin expands. This changes how reflective your skin is, and that change is what we track in our arduino. This means that places with the most blood flow, such as your finger tips and earlobes, give us the best signal.
While the pulse sensor comes with is long enough to hit your earlobe, you will probably have to extend it to hit your fingers (which is what i went for). Make sure you have a good solder joint, and use braided wire (not solid core) since this cable will be moving around a lot. Solder the pulse sensor to the arduino. Now the pendant should work when you plug in the battery, but we still have some nice features to add.
Connect the SPST switch. This will toggle between the "heartbeat mode", where we read from the heart sensor, to the "party mode", which just plays a nice changing heart shape rainbow. There is a hole in the left side of the case that switch can poke through once you hot glue it into place.
Finally the brightness nob. I added this last minute so there isn't an actual place to put it on the case. In the end i just glued it to the arduino itself, which is subpar, but you don't normally have to futz with that nob too often.
Once everything is wired up and tested, hot glue it all into place. I glued the board to the side of the case, and reinforced all the solder joints with a dollop of hot glue. In particular i added a bunch to the base of the heart sensor wires, since these will be moving around a lot and you dont want it working free. Secure the potentiometer to the board and the switch to the hole in the case. Also add glue between the terminals on each of these, so they are less likely to be worked free. Add the battery in (i did a small drop of glue so it doesn't rattle around, but i can still remove it later if need be).
The case has several sets of oval holes around the sides so you can thread whatever cord or straps you want to use to wear it (i just used a red ribbon through the top two holes).
And now we are pretty much done! Just thread the heart sensor through the little window in the lid, screw it into place, and now you have a working heart party pendant!
Step 5: Final Notes
Some things to be aware of:
- The 2500 mAh battery should last you several hours on the "party pattern" mode and much longer on the heart rate mode (since it uses much few LEDs at any given time). Cranking down the brightness will also make it last longer.
- The sensor works my measure your blood flow on your skin, so it works best on the parts of the body with a lot of bloodflow, like your finger tips and earlobes.
- When you first put on the sensor, or move it, it will take several seconds (~5-10) before it figures out the new signal. This is because the arduino has to watch a few beats go by before it can figure out the highs/lows of the signal, and pull the beat from that. When you move the sensor, it will usually beat erratically for a few seconds, then stop for a few seconds (which is a good sign). Once it picks back up it should be accurately tracking your heart.
- There is, unfortunately, a maximum heart rate that this version can handle. Whenever the beat animation is playing, the arduino can no longer gather heart signal data (this is because the neopixel library disables pin interrupts while it is updating the pixels). This means that as your heart rate gets higher, you will begin to see it "drop" beats, though i usually only see that as an issue when im moving around a ton.
Now you are ready to party!
There are a ton of little things I am dissatisfied with for this version. If people are interested, I can do a V2, which would probably feature a more compact PCB rather than hand soldered, better case with click-in lid, and a more reliable heart monitor. Let me know in the comments!