Data Logging Android/iOS App that Leverages Connectionless BLE GAP Advertisements to Minimize Power Consumption

A project log for Stomach Acid Powered Smart Pill

Zn-Cu stomach acid based bio-galvanic cell powers a hacked activity tracker small enough to swallow and reconfigured as a 'smart pill'.

curt-whiteCurt White 06/26/2018 at 16:530 Comments
UPDATE! Try out the app for yourself if you have android:

Now that the smartpill is wired up on a breadboard, it’s time create an app so we can log data wirelessly (and eventually through the abdomen). The big question is how to do this using Bluetooth BLE, a widely available standard that is not geared towards intermittent split second connectivity. Just connecting (“pairing”) over BLE can take seconds, while we want to turn the smartpill’s radio on for a fraction of a second. Luckily there is a way to transmit data over BLE without a connection: GAP advertisement information. Every BLE device constantly transmits basic information about itself – this is what you see when you scan for available Bluetooth devices. Only part of this information (“UUID”) is necessary, the spelled out name (“macbookabc”, “fitbit123”, “smartpillxyz” etc.) is for user convenience. Instead of using this extra ‘name’ information to advertise the smartpill for potential pairing, I use it to transmit data. Every time the smartpill turns on for a fraction of a second, it changes it’s BLE ‘name’ to the latest sensor values (for now voltage sensing ADC). My app is constantly scanning for new BLE devices (GAP advertisement information). The smartpill doesn’t have to wait for a connection to be created, the app grabs the sensor values from the advertised ‘name’ information the moment the smartpill is detected by the app. This dramatically decreases the length of time the smartpill’s Bluetooth radio has to be turned on which is crucial to minimizing power consumption.

I have used the Cordova based Evothings platform to create a hybrid Android/iOS app using web dev style Javascript. Evothings is, bar none, the easiest way to create apps for BLE devices. Anyone who knows a little JS/HTML/CS can pick it up quickly. Evothings sits on top of the venerable Cordova hybrid app creation framework. I have placed the Evothings project folder for this data logging app in the smartpill GitHub repository.