Given the choice between a) changing my lifestyle to be boring and b) hacking my metabolism, I chose the easier option. I built an artificial pancreas using OpenAPS! And it’s changing my life.
What’s an artificial pancreas?
• When your pancreas is not munted like mine, it produces insulin
• But more importantly, it knows when and how much insulin to produce – in response to the amount of glucose in your blood
• Everything affects this:
• – Food. Diabetics have to give themselves insulin for carbohydrates, using personal ratios we guess and refine. Different foods have different amounts of carbohydrates, which release at different speeds (glycaemic index). Companies are legally allowed to include an error margin of up to 10% on their nutritional information.
• – When you wake up (dawn phenoemenon / residual insulin effects – you need more insulin)
• – Illness and stress (you need more insulin)
• – Your current levels. Your body is more insulin resistant when your levels are higher than they should be.
• – Alcohol (occupies the liver, but only after more than one beer – you need less insulin)
• – Exercise (adrenaline makes it temporarily go up, and stabilises in the long run)
• – Sleep quality (makes metabolism more or less volatile)
• For diabetics, we are running mathematical optimizations of complex control systems, 24-7-365. Pulling levers, making guesses, trying to reduce our margins of error.
• An artificial pancreas is just this – but 80% is automated.
This post is a little blog of my experience building such a system. I’ve outlined the tech and costs of buying it, the research involved and assembly. And most of all – the actual human impact it is making on my life. Let’s begin!
The Tech Stack
• FreeStyle Libre CGM – continuous glucose monitoring
• Miaomiao transmitter – transmits the Libre (which is NFC-based) readings via Bluetooth to my phone
• Nightscout deployment on Heroku – an open-source frontend/backend for T1 Diabetes data hosting and visualisation
• self-signed xDrip app – an open-source app which receives readings via Bluetooth, and sends them to Nightscout
• Medtronic Insulin Pump – to inject insulin
• Intel Edison + Explorer HAT – a Linux electronic board with WiFi and support for 900MhZ radio comms
• 4400mA Lithium Ion battery – to power the “rig” on-the-go
• OpenAPS – the ‘operating system’ of the artificial pancreas rig. Downloads readings from Nightscout, dynamically predicts and adjusts background insulin delivery on the insulin pump via radio, uploads all of this data to Nightscout for continuous monitoring.
Costs
Costs are in AUD and EUR.
Insulin pump – I already had this from years ago, but usually around €3100/$5000.
FreeStyle Libre CGM – €70/$112 for the reader (one time cost), and €70/$112 per sensor (which lasts 14 days, so €140/$225/month)
Miaomiao – this was €200/$322
Hosting Nightscout on Heroku. Free.
xDrip app. The app is open-source, but since Apple doesn’t allow it in App Stores, I had to purchase a 1 year developer license to sign and install it on my phone. €93/$150
Intel Edison. Even though these boards are no longer sold by Intel, it was still rather cheap. €57/$92 (including shipping of €12/$20).
Explorer HAT. This piece is a bespoke product made by a company called Enhanced Radio in the US. €68/$109, although I had to pay Dutch import tax of like €20/$32 because I forgot this was outside the US.
Lithium Ion battery. Opted for a battery twice the capacity as the docs, just to err on the side of caution. €50/$81 (including shipping of €22/$36, and taxes €8/$13).
OpenAPS. Open-source ![😉](https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/svg/1f609.svg)
Total fixed costs (excluding pump):
€608/$979
Total monthly costs (excluding insulin):
€140/$225
The timeline
Stage 1: Research
There was quite a lot of research involved, and definitely more to come. Some things I had to understand:
• which insulin pump I had, and whether it could be hacked to run this system
• comparing the different open-source systems. There’s another called Loop, which is an iOS app, that uses a custom board called RileyLink. There’s also an Android port, called AndroidAPS.
• whether I could get this working with FreeStyle Libre – which is the cheapest and most easily-purchasable CGM (you can’t just buy these things off Amazon) but definitely not the most ubiquitous.
• after choosing to build on OpenAPS, having to decide which of the Intel Edison or Raspberry Pi I would choose. I ended up selecting the Edison, since it’s got much better power efficiency than the Pi.
Estimate: 7 hours
Stage 2: Ordering
All of these parts came from different places:
• The Edison has been out-of-production for 2 years now. I had to do a bit of sleuthing on Amazon and various other sites to find one. Eventually I found a seller on eBay who shipped from the US.
• The Explorer HAT was ordered from the US, easily through the one supplier.
• The Miaomiao took the longest out of all (2-3 weeks), coming from some dodgy place in China (despite being a Brazilian company).
• The battery (and some extra assembly bits) was ordered from Adafruit (a very reputable online electronics company), again coming from the US, but different shipping company.
Total time waiting: 3 weeks
I spent my $1000, sent them to my business address, and then went to Sweden and Finland while I was waiting.
This also misses the part where I had to go to the Dutch post office to pickup one of the packages, because apparently I owed import taxes on it.
Stage 3: Assembly
I was so excited to get this thing setup.
Estimated time: 9 hours
This stage took the longest. Why?
• 1 hour in total. I had to read the OpenAPS documentation, which is long. Very long.
• 2 hours. Downloading Jubilinux and properly flashing the Edison, over a microUSB cable. Fun fact – there are microUSBs cables that support data, and ones that don’t!
• 2.5 hours. Downloading packages/dependencies using APT and NPM on a microcomputer. Then downloading them again, because OpenAPS is just a collection of rudimentary Bash scripts.
• 1 hour. I had to buy an Apple Developer License and learn how sign and install this xDrip app.
• 1 hour. Getting Nightscout setup on Heroku, with proper authentication and specific plugins for the OpenAPS system. Then adding these credentials to xDrip on my phone, and to OpenAPS
• 2 hours. Debugging why my loop was not running properly. For some reason, it couldn’t get the levels from Nightscout. I spent some time, cat ‘ing various logs, before I jumped into the nightscout/intend-to-bolus channel on Gitter. Within an hour, the very friendly folks were able to help me – we found the source of the issue was with the Tomato uploader, and I swapped to using Xdrip.
No comments:
Post a Comment