Perl scripts analyze Jawbone UP data
Moving Circle
The Jawbone UP electronic bracelet measures the wearer's daily activity and nocturnal sleep patterns. If you are bored by the official smartphone app, you can create your own Perl scripts and access your data via the unofficial web API.
To counter the widespread tendency to excessive body fat, many smartphone owners now carry little gadgets around with them, reminding them of their lack of physical activity during the day. If you sit motionless for hours in front of the screen, the idea is that such a device could motivate you to walk around the block more often, or at least use the upstairs bathroom. This trend toward self-measurement – known as quantifying yourself – has grown very popular lately.
An electronic bracelet like the UP [1] by Jawbone measures the steps you take and shows the distance traveled and calories burned in the associated smartphone app (Figure 1). The accessory is available in three sizes and several colors and costs about US$ 130. From a functional point of view, the device seems to capture only instantaneous acceleration values and accumulates them over time. The geographical position of the wearer could be determined with a GPS chip, but this added function would probably drain the device's small battery in next to no time.
Under the Hood
As a specialist in lifestyle gadgets, Jawbone is not exactly a proponent of open hardware; but in a YouTube video [2], an inquisitive geek slit open the outer rubber shell of the bracelet to reveal the waterproof sealed components inside (Figure 2). In the course of this operation, the bold explorer found half a dozen smaller mini-PCBs with SMD components, but apart from an accelerometer, the lithium-ion battery and charger chip, a vibration device, and components for docking to the audio port of the smartphone, nothing flashy was revealed.
In other words, after connecting to the smartphone, the bracelet simply sends the timed acceleration data to a machine learning system in the Jawbone cloud, which then looks at the movement patterns and guesses by the type of movement (walking, running, elliptical trainer) how many steps the wearer managed and what distance was covered.
Sleep of the Just
If you wear the UP band at night, you can marvel at your sleep patterns in the morning. The app shows graphically when you went to bed, when you fell asleep, and how many times you woke up or got up during the night. Upon request, the band can wake you with a gentle vibration within a 20-minute period in the sleep cycle when waking up will cause the least pain.
To detect the sleep pattern, however, you first need to press a button to switch the device manually to sleep mode. If you do not move for a long time after this, you are probably fast asleep; if smaller movements are detected, you are in a lighter phase of sleep.
The built-in battery lasts for about a week without recharging. To read the data, you need to pull the silver cap off one end of the UP to reveal an audio connector. You then plug the connector into the audio port on your smartphone (Figure 3) and launch the app. The UP sends the movement data to the app, which forwards it to the server in the Jawbone cloud. The app receives the processed data and displays it in nicely arranged graphs (Figures 4 and 5).
You can share the information that UP gathers with other users. For example, runners can invite friends to join their "team" and organize fitness competitions. If you prefer not to let your colleagues know that you spent the whole night tossing and turning in bed, you can exclude this delicate information from publication in the Sharing section.
Open Data
The device is interesting for hobbyists because the step and sleep data is available not only via the app but also in a raw format. To access the data, the script in Listing 1 calls on the CPAN WWW::Jawbone::Up module, and thus indirectly an unofficial web API that imports the transaction data into a Perl script [3]. Running ./uptest
at the Linux command line allows the experiment-friendly fitness enthusiast to quickly query the data they have already uploaded:
Listing 1
uptest
Mike Schilli walked 8.597km today Mike Schilli slept for 6h19m last night
Listing 1 starts by loading the CPAN module and then logs in to the UP cloud using the connect()
method. You need to replace the email address and password in lines 11 and 12 with your UP user account credentials, which you created when you activated your UP. The user()
method retrieves the registration data of the logged in user. The name()
method extracts the user's first and last name.
The score()
method then pulls the processed motion data from the UP server. The distance traveled by the wearer in the past 24 hours can be queried in kilometers using move()->distance()
. If you prefer miles, you can simply multiply the value by 0.62.
The sleep duration in seconds is provided by sleep()->asleep()
. The next line divides the value by 60 to arrive at minutes, and the CPAN module DateTime::Duration converts the resulting value to hours and minutes. It refuses to cooperate with seconds because this could lead to errors in special cases (because of leap seconds), so you need this trick to get it to cooperate.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.