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.