Get your hands on Whiskers by backing the Whisker Kickstarter Today!!
There are many fitness trackers on the market today, but most of them do not give users the ability to easily add custom software or hardware. In this tutorial, you will learn how to do both! TinyCircuits Whiskers allow you to choose between 30 unique sensors for your projects! This is a new step forward in the Quantified Self movement!
For our custom fitness tracker, we chose to use the accelerometer, pulse oximetry, and LRA (tiny vibrating motor) whiskers. Our goal was to track our steps using the accelerometer and issue notifications using the LRA. Then, using the pulse oximetry whisker we would be able to measure your heart rate and blood oxygen level.
In addition, we created a sleep tracker functionality! By observing the nightly movement of the user and their heart rate, we were able to measure sleep quality and duration. Based on this study, we know that heart rates alone provide a significant clue as to which sleep stage you are in.
Of course, there are many other interesting combinations. Using the general tips provided in this article, you will be able to easily modify our code to match with any whisker you choose!
With each Whisker Adapter TinyShield, you can connect up to 4 additional whiskers to the rest of the TinyCircuits ecosystem
Here, the pulse whisker measures the rhythmic flow of blood into and out of your finger. The small noose keeps a light, steady pressure to ensure the most accurate readings.
If this is your first time using TinyCircuits products, please refer to the TinyScreen+ Setup Tutorial to configure the Arduino IDE correctly.
When using the Whisker Adapter TinyShield, it is important to understand port selection. You must indicate in your sketch which port each Whisker is using. Note that the port numbers are printed on the reverse side of the TinyShield. The 4 ports are numbered 0-3.
The good news is that our sketch is able to automatically detect which port the Accelerometer, LRA, and Pulse Oximetry Whiskers have been connected to.
If you want the ability to record audio using the MEMS Microphone Whisker, you would need to choose a specific port number and always connect the Microphone Whisker to the same port. Then, in your sketch, you would only need two lines to read data from the Whisker.
selectPort(1); // Correlates to port numbers labeled on Whisker device analogRead(A1); // Same number as port number
There are a few parameters that you can set at this stage to personalize your fitness tracker. In order to set them, navigate to the line shown in the table and modify the value to the right of the equals sign.
const int AGE = 25; // age has a significant impact on sleep composition, so inputting your age will increase the accuracy of your sleep quality calculation
const int STEP_TRIGGER = 250; // The LRA whisker will notify you of inactivity if you complete less than half of this number of steps each hour. Step % is based on this * 16 waking hours.
/* Change these values to set the current time when you upload the sketch. */ const byte seconds = 10; const byte minutes = 52; const byte hours = 23; /* Change these values to set the current initial date */ const byte day = 16; const byte month = 8; const byte year = 19;
const int BEDTIME_HOUR = 23; // use 24 hour time only. const int BEDTIME_MINUTE = 53;
The library manager can be found by going to Tools-> Manage Libraries in the Arduino IDE
At this point, the tracker will begin monitoring the time, step count for the current day, percentage of your step goal, pulse, oxygen saturation, and remaining battery percentage. Also, once the tracker has detected that you have fallen asleep it will measure your sleep quality and determine your current sleep stage. All data is recorded to tracker.txt in a CSV format every 30 seconds by default.
Another text file called quartiles.txt will store quartile data of your heart rate at night. It is intended to be read by the sleep quality algorithm. Since everyone's heart rate varies, it is much more accurate to base calculations off of your past heart rate than preprogrammed values. Avoid editing the format of this file or it will not be read properly by the sketch.
Finally, a third file called sleephistory.txt is created. This file contains two columns in a CSV format, the date and the sleep quality for that date. It is updated every morning when you wake up and contains more accurate information after your sleep chronology was analyzed. Sleep chronology contrasts your sleep stage transitions against the optimal configuration of lighter sleep at the beginning and end of the night and deeper sleep in the middle.
This is just the beginning of what you can accomplish using whisker sensors! See the optional tips below for how to incorporate any whisker into your own sketches. If you need any help, feel free to email us at email@example.com!
Depending on the whisker, you may need to #include a library.
#include "TinyCircuits_A1454.h" // For the sensor
TinyCircuits_A1454 hall = TinyCircuits_A1454();
Finally, read from the sensor and store the value into a variable.
long mag = hall.readMag();
As always, if you have any questions or feedback, feel free to email us at firstname.lastname@example.org. We would love to hear any ideas for improvement or new IoT projects you were inspired to work on!
Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!
Thanks for making with us!!