Building a DIY Artificial Pancreas

Add them together & what do we have?

I am going to build a fully wireless, closed loop DIY Artificial Pancreas System to partly automate the management of my Diabetes.

That's it, I said it, I better do it then...

As those who know me I have been quite excited since coming back travelling about the progress of tech in the Type 1 Diabetes community. Mainly the #WeAreNotWaiting movement who are are a group of Type 1 Diabetics / supporters hacking current closed Diabetes tech and building very cool projects on top.

One such project that is pulling in many different smaller projects is to build a fully DIY Artificial Pancreas.


Why? | CGM + Pump + me = not ideal

As a Type 1 Diabetic I have 24/7/365 days a year of playing Glucose level balancing . Too much insulin, my blood sugars plummet and I could go into a coma, not enough and I have high blood sugars, feel really crap and with possible long term complications of having a shorter life expectancy, losing my sight or limbs.

In a nutshell - it is in my interest to have balanced blood sugars.

There are two key elements to this balancing, knowing what my blood sugars are and administrating Insulin. (There are many more variables, but lets stick to the basics.)

Knowing my blood sugars

I have a Continuous Glucose Monitor (CGM) this provides a reading every 5 mins of my blood glucose and provides a graph so I can see what my history has been and if I am treading in any direction, up, down or if I'm lucky straight.

Ideally, that line should be straight
Ideally, that line should be straight

Delivering Insulin

I have a Roche Accu-Chek Combo Insulin pump, this has a basic profile of of my insulin needs throughout the day, performs basic calculations on how much Insulin I need for Carbs consumed, can do cool little tricks like reduce or increase the percentage of my Insulin being delivered and different Bolus types (larger injections of Insulin) all to a 0.01 ml accuracy. This is not automated, all based on the information \ settings I provide.

My Pump & Meter
My Pump & Meter

The Brains

Well that would be me, unfortunately this is where we start to have issues.
I do not have the time to make complex calculations every 5mins based on my current blood sugar, my Insulin on Board (IOB), Carbs on Board (COB) and trend path I am currently on. Therefore I do this approx 100+ times a day when I remember, feel crappy or my CGM alarm goes off as I am in the danger zone of too high or low. Also, I am off-line for approx 8 hours a day and an impatient human who wants to fix my high or low blood sugar situation by possibly taking too much Insulin or eating too many Carbs. Oh, also, I need to remember what I did before as Insulin and Carbs can take up to an hour or longer to take action.

I am the weak part of the chain.


The Artificial Pancreas

The basic formula for managing blood sugars is very simple:

  • Blood sugars trending a little high, IOB is low = deliver a little Insulin
  • Blood sugars trending a little low, not enough COB = reduce the amount of Insulin
    (Yes, it is a little more complex than that, but lets keep things simple for now)

While this will not fully automate my medication, it will cover me 70% of the time. For understanding my Insulin and Carbs sensitivity, Carbs being consumed and other factors like illness, exercises etc I will still need to make manual calculations. With this formula being utilised I will lower the chance of unexpected highs and low blood glucose levels, reduce the mental stress of worrying about how my blood sugars are and if needed alert me when attention is required for example sugars dropping too quickly. I could automate a large amount of my Diabetes management.



I have the data, but as we see in all industries at some point this is in closed non standard data silos that cost a lot to access or restricted to lock you into the product you have. I own my data, but getting access to it under my terms is a world of pain.

My project is broken into the 3 key stages \ challenges...

1: CGM | Reducing the cost and getting access to data

CGMs are only covered by the NHS in extreme cases. If you want one this will most likely be self funded, the cost for a Dexcom G4 CGM looks like the following...

  • The Receiver (receives and displays your readings): £1075 - lasts 2 / 3 years until the NON STANDARD charging port goes bust
  • The Transmitter (clips onto the sensor and sends your readings to the Receiver): £350 every 6 months
  • Sensors (the bit that goes inside you): £62.50 every week
  • VAT free but excludes postage (Don't even get me started)

So that's a total of £4675* for the first year (£3950 / year after), self funded - WTF? No really, talk about making money from the sick, I hope the Dexcom board of directors are really happy with themselves.

*Only one Transmitter needed, as Receiver comes with a Transmitter.

Challenge 1 | Reduce the cost of a CGM

There is a very clever guy called Stephen Black who has made a device called xDrip (was dexDrip), this picks up the signal from the Transmitter and relays it via Bluetooth to your mobile where an app crunches the data and produces a lovely graph.

  • Swap Receiver (£1075) for xDrip (around £30 excluding mobile)
  • Saving: £1025

The only reason the Transmitter needs to be replaced every 6 months is due to the batteries dying. As I have already done with the Dexcom 7+ you are able to open a dead receiver and replace the batteries.

  • Manually replace batteries yourself in a dead receiver, £2 every 6 months
  • Saving: £696 year (based on getting a Transmitter that someone was about to bin)

There are also tricks with the sensor that will allow you to reuse it, some have been able to use one sensor for 4+ weeks.

  • Extend sensor life to 3 weeks (£1125)
  • Saving: £2125 year

Final total: £1157 first year, £1129 year after. Or, in others words slightly more affordable.

Challenge 2 | Access to CGM data

As xDrip relays YOUR data to your mobile where YOU have full control you can do what you want with the data, for example upload to NightScout to provide CGM data in the Cloud so you can access it anywhere, smartwatch, partners mobile, Internet connected fridge - how cool its is when you can access YOUR DATA and do what you want with it?

2: Pump | Controlled from my mobile

My pump uses Bluetooth to talk to its partner the blood testing meter (a device that reads blood sugars from blood, google it), my mobile has Bluetooth - YAY! Lets just talk to my pump from my mobile.

Yeah, as if it would be as simple as linking your Bluetooth headset to your mobile . The authentication and commands sent between the meter and pump are surrounded in secrets, to get access to this info we need to get dirty and enter the world of Bluetooth sniffing and hacking. So far I have purchased an Ubertooth, a device that can monitor Bluetooth traffic and collecting lots and lots of data. Unfortunately I have very little idea of what this data means.

3: The Brains

This, while being the part of the system that will make all the calculations is one of the easier areas. Dana Lewis and Scott Leibrand have gone from solving a small issue of making the CGM alarms louder to producing a full closed loop DIY Artificial Pancreas #DIYPS. Really, these guys rock and started to provide a reference design for others to follow. While there is not much code on there, the logic is shared so that others can and build their own systems and work together.

This will end up being an Android app that takes the incoming CGM data, crunch the numbers and send commands to the pump. Unlike current examples this will not require cables connected to the devices and miniature computers to be carried around, this will all work wirelessly with my phone as the command centre. Brings a whole new pain to "I lost my mobile"!


Can you help?

I will be documenting and sharing as much information as possible on this blog as I complete each stage. If you are interested in my current progress checkout my thread on OpenAPS Dev Google Group.

If you are an Android App developer, knowledgeable at all in the inner workings of Bluetooth, willing to work for beer - get in contact.

Project site:


Like this? Email me future posts!


The contents of this site is for informational purposes only and is not intended to be a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your Diabetes support team or other qualified health provider with any questions you may have regarding your medical condition.Sorry, have to say something like this!