Filter results by

Quick Apps: Sync With a Pill

We did a fun demo for the Samsung booth at Health-IT 2015 in Paris this week. We connected a BodyCap e-Celsius device with SAMI. e-Celsius is an ingestible pill which measures your core temperature and transmits the data to your smartphone or tablet, making it simple for medical staff to remotely assess your temperature.

First, watch this video to see our demo in action:

 

BodyCap is a French start-up specializing in miniature electronic sensors and monitors for continual measurement of patients’ physiological variables in diagnostic or research scenarios. e-Celsius is awaiting approval for use in the next couple of months, and BodyCap is considering FDA approval for the U.S.

BodyCap e-Celsius

e-Celsius sends data using a custom radio frequency. Initially in development, the signal was received on a complete custom device to display the temperature (the monitors in the above illustration). However, Bodycap is now moving to a custom USB dongle that is plugged into a smartphone or tablet.

We developed a new Android application to get the data from the USB dongle and to display the temperature and send it to SAMI. We needed to use two different Android libraries to support the dongles: PhysicaloidLibrary and FTDriver.

Data is sent to SAMI using the REST API and using a device token.

To get started, we logged into the SAMI User Portal and connected a new device representing e-Celsius. Following these steps, it’s easy to get the device ID and generate a device token from within the User Portal.

Once the app has the device ID and device token, the user doesn’t have to log into SAMI, as device tokens have no expiration time. Of course, for a final product, this is not the best solution because you need to enter the device ID and token, which is difficult. To go to production, we would use an Authorization Code method and user token for authentication.

We send data using a single POST:

POST /messages

Data are sent every 30 sec, so there is no need for WebSockets.

When data are in SAMI we can do anything we want, and that’s the fun part. A small application connected to SAMI listens to the data coming from this device ID and sends an email if the temperature reaches a certain threshold. This simulates an alert notification that could be sent to a doctor.

Below the code we used to send data to SAMI.

Build a JSON message from the device ID and the temperature:

 1 public void publishTemperatureInSami(float temperature)
 2   {
 3     try {
 4       JSONObject jsonObject = new JSONObject();
 5       jsonObject.accumulate("sdid", deviceId);
 6       jsonObject.accumulate("type", "message");
 7 
 8       JSONObject jsonData = new JSONObject();
 9       jsonData.accumulate("temp", temperature);
10       jsonObject.accumulate("data", jsonData);
11       String json = jsonObject.toString();
12       StringEntity entity = new StringEntity(json);

Then create the POST request and post it.

 1 ...
 2       client.addHeader("Authorization", "Bearer " + deviceToken);
 3       client.post(getApplicationContext(), "https://api.samsungsami.io/v1.1/messages", entity, "application/json",
 4         new AsyncHttpResponseHandler() {
 5           @Override
 6           public void onSuccess(int i, Header[] headers, byte[] bytes) {
 7             for(Header h : headers)
 8               if(h.getName().equals("X-Rate-Limit-Remaining")) {
 9                 // DO SOMETHING ABOUT RATE LIMIT
10             }
11           }
12 
13           @Override
14           public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
15             // DO SOMETHING ON FAILURE
16           }
17         }
18       });
19     }
20     catch(Exception e)
21    {
22      // MANAGE EXCEPTION
23    }
24   }

Although the SAMI application was just a proof of concept we did in collaboration with BodyCap, we were all very happy with the ease of connecting this new device to SAMI.

Top image by Arturo Castellanos

Get the ARTIK Newsletter

You like your news fresh! Sign up now and you will be the first to know about our latest software releases, coding tips, upcoming events, blog posts, datasheet updates, and more.

* By checking either box, you may receive notifications by phone, email, text, and/or other electronic means from Samsung Semiconductor, Inc. and its affiliates. If you choose to receive partner notifications, we may forward your contact information to our partners. You may unsubscribe from these services at any time by clicking on the unsubscribe link in our communications or by submitting a request here. Please see our Privacy Policy and Terms of Use for more information about how your data is stored and used.