By Gustavo Armagno

ShakeJake is a wearable device that unobtrusively detects handshakes. It has been conceived and developed by Moove-it, who brought together a cross-disciplinary team of electronic engineers, an iOS developer, a Ruby developer and a UX designer for its creation.

Although Moove-it’s main focus is providing Ruby, Java and mobile development services, we are always dreaming up new products to build. On this occasion, we wanted to take something innovative to RubyConf San Antonio, that combined both Ruby and IoT technologies.

The guiding principle that led to building this particular wearable device was: “how to make networking less scary and more fun”. The product idea we came up with was a mobile app that automagically detects each time the user shakes someone’s hand, keeps track of handshakes and encourages both parties to exchange contact information.

To solve the automagical thing, we decided to build an electronic wristband using capacitive touch sensors, the same principle as underlies the touchscreens used in most smartphones. When the wearable detects a handshake, it sends a bluetooth message to a smartphone connected to the device. A mobile app installed in the phone receives the bluetooth signal, which then triggers the app’s logic.

In order to keep track of handshakes and save contact data, the mobile app connects with a server endpoint, implemented in Ruby.

The fun part comes in the form of Jake, a digital narrator who chimes in when the system detects a handshake, encouraging both individuals to share their contact information.

Let’s get into the technical details.

The hardware

Note: I know almost nothing about electronics. However, I asked the electronic engineers to explain the secret behind the magic to me and, after filtering out some of the more complex technicalities, it is pretty straightforward to understand.

hand_with_wrist

The circuitry embedded in the wristband is shown, below. It basically consists of a microcontroller (an Arduino), two metallic plates serving as a capacitor, a multiplexer, a sample-and-hold circuit, an analog-digital converter and stuffing circuits.

ShakeJake_1

The x pF capacitor represents the capacitance between the two plates at the wrist. One plate is connected to one of the microcontroller’s ground pins and the other to one of the inputs that are able to take analogic measurements.

The sample-and-hold (S&H) circuit samples the varying voltage emitted by the input signal and holds its value at a constant level in the 14 pF capacitor until the reading is done.

When the ADC finishes reading the sample, the 14 pF capacitor needs to be discharged in order to be able to take a new measurement. This is done by the multiplexor, which connects the capacitor’s input to ground, allowing it to get a 0V state again.

ShakeJake works by measuring the capacitance between the two adjacent plates (x pF capacitor), using the internal sampling capacitor (14 pF) as a bridge measurement system.

In order to measure the capacitance between the plates, the algorithm embedded in the microcontroller makes a two step iteration: charging and measuring.

Step 1: Charging

ShakeJake_2

When the pull-up resistor is enabled (ON), the external capacitor (x pF) between the plates is charged up to 3.3V.

In parallel, the multiplexer switches its input to ground and discharges the measuring capacitor (14 pF) in order to prepare it to take a new measurement.

Step 2: Measuring

Once both capacitors reach a steady state, the pull-up resistor is disabled (OFF) and the multiplexer connects the input signal to the ADC. The capacitors get connected in parallel, causing some current to flow from the external plates (x pF) to the internal capacitor (14 pF). The voltage read by the ADC depends on the gap between both capacitances.

The presence of an object over the external plates (x pF) modifies the amount of energy that can be stored in them and, as a consequence, the electrical current that is going to flow from them to the internal capacitor. The crucial factor is that objects sharing the same material characteristics, like human skin, produce similar variations in the aforementioned amount of energy, so we can identify the presence of certain materials by measuring the amount of energy that flows from the plates.

The algorithm running in the microcontroller performs this identification and classification process, allowing ShakeJake to detect the proximity of the hand wearing the wristband to any hand that is presented to it. The procedure defining the threshold that identifies a handshake is quite straightforward. First, the microcontroller takes a training data set, divided in two groups, one that represents handshake measurements, and the other representing the opposite. If we accept that each group follows a gaussian distribution, we can model its expression with its mean and variance.

When we take a new measurement, we want to respond to the question “given this new value, is it probable that the user is shaking hands?”. Using the previously determined probability distributions, we can find the answer quite easily: if the distribution that corresponds to the handshake measurements is larger than the other one, when we evaluate them at the measurement value, then it is probable that we are shaking hands with someone.

To make this process more efficient we identify the point at which those two distributions are equal at the calibration stage. Then, if the new measurement is greater than that point, we are shaking hands, otherwise we are not.

ShakeJake_3

The mobile app

The wrist-wearable device uses Bluetooth Low Energy (BLE) to communicate with the smartphone (an iPhone). The main difference between BLE and Bluetooth Classic is that BLE’s standard version is much more limited in scope, when compared to Classic’s, and thus requires very low power to transmit messages. This feature makes BLE a better choice to use on devices with very limited power, like wearables.

Another benefit of using BLE is that, unlike Classic, you don’t need to pass any special Apple certification to use the protocol. To create accessories based on Bluetooth Classic, you need to join Apple’s MFi licensing program and only use connectors and components authorized by Apple.

Other than that, ShakeJake’s mobile app is a pretty standard Swift app (latest version) with only a limited number of views. The main job of the logic is to synchronize the mobile app with the wrist’s three states: PAUSED, CALIBRATING and SAMPLING.

First, the user needs to connect the app with the wristband. This is done from the Sampling view, by tapping on the Settings option and, once in the Settings view, choosing to pair with the device. The app always makes sure that, when the user is in the Settings view, the wristband is in PAUSED mode.

Once the app connects to the wristband through the BLE channel, the user has the option of calibrating the device, from the Settings view. If that option is selected, the app sends a “calibrate” command to the wristband to start the calibration process. This action puts the wristband in CALIBRATING mode.

Authentication to device calibration's flow
Authentication to device calibration’s flow

Calibrating the system means shaking someone’s hand to correctly classify human skin under the existing environmental conditions at that location. This is fundamental, because changing weather conditions—and, in particular, humidity—affects skin conductance and may lead to an inaccurate classification.

Once the device has been successfully calibrated, the app switches the wristband back to PAUSED mode. When the user leaves Settings, the app switches the device’s state to SAMPLING, which then allows it to start detecting handshakes.

The user can go back to Settings at any time and the workflow will repeat itself.

When the device is in SAMPLING mode and detects a handshake, it sends a message containing the word “HAND” to the app. When it detects the end of a handshake, it sends a “JAKE” and, in a new line, the duration of the handshake in milliseconds. This action allows the app to trigger Jake’s voice and open the Save Contact view.

mobile_shaking
Handshake detection to save contact’s flow

In the Save Contact view, the user can enter the other individual’s name, email and Twitter handle. The app then submits this data to the server, running in Ruby.

The Ruby backend

The backend API has been implemented using Angus, a lightweight open-source framework aimed at easily developing RESTful APIs.

The API registers contacts and keeps track of handshakes.

One of the benefits of using Angus is that it automatically generates the API specification straight from the code, without the need to write any additional documentation. ShakeJake’s API specs can be found at https://moove-it.com/shake_jake/doc/0.1.

The number of handshakes is accumulated and stored in a database in order to be accessed and shown on ShakeJake’s landing page. This feature has been specially developed for the RubyConf. The goal here is to let the world know how many people we meet at the conference.

The backend service uses Rusen to log errors and send them via email. Error notifications include: information about the current request, session, environment and a backtrace of exceptions.

Conclusion

The whole system is a minimum viable product (MVP)—which also served as a feasibility test—aimed to test the product’s value hypothesis, which is: people would feel more motivated to meet new people if they had an app that counted the number of handshakes they received and registered new contacts in a fun and interesting way.

gusa_and_ariel

We believe that the RubyConf presents us with a great test scenario to evaluate this MVP, where we can learn from a real use case and interact with lots of potential adopters.

Future work

We foresee a lot of potential uses for this technology that go beyond networking during events.

One potential use is to enhance the existing market for digital business card apps, by offering greater accessibility. The system’s main input is tactile and one of the main interaction channels is auditory. In the future, it could incorporate voice input and be used by visually challenged people as a substitute tool for similar apps already in existence.

Another possible use could be, where two people wearing wristbands shake hands, turning the system into a secure and fun mechanism for them to exchange information.

A third use we have thought of, is using a similar mechanism to detect different behavioural patterns and even to recognize people or objects that users have already touched before. This sounds more like science fiction, but the technology is out there and Disney Research has published a paper about this very topic. We are currently working on building something similar that can be transportable, so watch this space!

Check out how many handshakes we’ve done so far at ShakeJake’s landing page.