How-To

How we “hacked” diabetes with the Internet of Things

I just finished up my second semester formally studying Computer Science as a 49-year-old college student. I already have a degree, so I’m pursuing a Software Engineering Certificate at my local community college. Although I never thought my student life would intersect with the IoT world, I was pleasantly surprised that it recently did.

For our final group project, we could literally do anything we wanted, so long as it showcased our relatively new programming skills. It turns out that one of my classmates has diabetes and she suggested we try to implement a “closed-loop” system for her insulin pump.

By closed-loop, I mean that the insulin pump has software that automatically adjusts insulin delivery based on the patient’s glucose levels. Most pumps on the market today don’t do this; instead, the patient periodically checks their blood sugar readings and manually increases or decreases insulin delivery.

After several weeks of research, we decided to implement the closed-loop system with an open source project called OpenAPS. This project adds the closed-loop smarts to regular, manual insulin pumps although it only works with very specific pumps: The firmware on most FDA-approved insulin pumps is locked down.

We bought an older pump that works with the OpenAPS code and had to add a few connected bits of hardware: A Glucometer with USB connectivity, a Raspberry Pi to run the algorithm, a 900MHz radio for the Pi to send commands to the insulin pump and a portable battery to power the Pi.

Once we got the project running, blood sugar levels were gathered by the glucometer – which we kept connected to an Android phone – every five minutes. We installed an Android app called NightScout, which sends the data up to the cloud where we had already set up a Heroku web app and MongoDB database to accumulate the blood sugar levels.

In just a few weeks we had nearly 10,000 readings sent to the cloud, which in turn were run through the algorithm on the Raspberry Pi when it was connected to a Wi-Fi network. Using that data, insulin delivery rates were continuously adjusted by sending commands from the Pi to the pump, creating the closed-loop system.

We decided to take things a step further with some additional programming skills though, so we created code to automatically read and reformat the blood sugar readings into a Google Sheet. Then, using Google DataStudio, we were able to create custom charts showing both blood sugar levels and insulin delivery. These charts can be sent on a scheduled basis to a health-care provider.

Given that I had already used light bulbs for ambient notifications in the past, we took things one step further by using the data to change the color of a smart light bulb. The thought was that perhaps a school nurse could have one of these for any school children with diabetes using our system. If the student’s blood sugar levels were too high or too low, the bulb color would indicate this so that any appropriate steps could be taken.

That was easy to implement with a LIFX bulb and the LIFX API. With just a few lines of code reading from the Google Sheet on a regular basis, we were able to make this happen.

Ideally, we wanted to shrink this solution down to a small LED wearable device, but the semester ended before we could implement it.

After we presented the project, it really hit me how much the IoT can be applied to nearly any problem or challenge. Sometimes you need to think outside the box to get past the traditional “control your smart home” or “monitor a production process” use cases.

If you’ve got useful data and want to bring some AI or other smarts to it, the IoT can be a powerful tool. And that may be the most impactful lesson we learned during this coding effort.

To see all of the project details, hit our project website here.

Kevin C. Tofel

Share
Published by
Kevin C. Tofel

Recent Posts

Episode 437: Goodbye and good luck

This is the final episode of The Internet of Things Podcast, and to send us…

8 months ago

So long, and thanks for all the insights

This article was originally published in my weekly IoT newsletter on Friday August 18, 2023.…

8 months ago

We are entering our maintenance era

This article was originally published in my weekly IoT newsletter on Friday August 18, 2023.…

8 months ago

IoT news of the week for August 18, 2023

Verdigris has raised $10M for smarter buildings: I am so excited by this news, because roughly eight…

8 months ago

Podcast: Can Alexa (and the smart home) stand on its own?

Amazon's head of devices, David Limp, plans to retire as part of a wave of executives that…

8 months ago

Z-Wave gets a boost with new chip provider

If you need any more indication that Matter is not going to kill all of…

9 months ago