How do I loop? How to get started with DIY “Artificial Pancreas” systems

If you’ve found this page, then you are looking to get started with looping. You’ve realised that you want to try offloading the responsibility for trying to manage your diabetes to an unemotional application that can make recommendations based on numbers and models, and not emotional responses to conditions.

A range of options! How great is that?

So that’s where we’ll start. The options presented here vary in levels of complexity and difficulty to set up and are recommendations. Ultimately you will be making the decision as to where you start, but I’ve tried to provide some guidance as to what I think.

The details provided here are links to the various documentation and set-up guides along with my take on how easy it is to do. Whichever option you elect to take, there are many people willing to help you get running via the channels for these apps. This references both open loop (where the user has to interact with a pump to action the suggestion) and closed loop (where the algorithm speaks directly with the pump to adjust insulin levels).

All systems require the use of CGM and a pump to get the best out of them. Some require more code based configuration than others, where you’ll need to either change python or Swift files, or be comfortable modifying bash scripts and Cron tabs.

I strongly suggest starting with open loop and progressing to a closed loop as it provides the best mechanism for learning how you interact with it. This was the approach that I’ve taken, and you can read more about it in this post.

Open Loop

There are three apps that support open loop out of the box. HAPP, Loop and AndroidAPS. As HAPP is only open loop and doesn’t need to talk to a pump for data, I’ve covered that here. Loop and AndroidAPS can be found in the closed loop section.

Hackability Artificial Pancreas Project (HAPP)

HAPP is an open loop implementation of the OpenAPS oref0 algorithm for use on an Android smartphone. It contains a bolus calculator and can send data to a smartwatch to tell you when to adjust your basal rate to minimise highs and lows. This is, in my view, the easiest to set up and a great way to get to know the ins and outs of how loop algorithms work. It was built by Tim Omer as he looked for a way to better manage his diabetes.

HAPP gives you an offline platform that you can use when out of mobile or wifi coverage, but I like to run all of these things with a Nightscout implementation as the tool is excellent for reviewing both what you’ve done and the decisions that the platform has made.

Required Hardware:

  • Dexcom G5 CGM or Dexcom G4 with xDrip and Wireless Bridge (self-build)
  • Alternatively, the Libre sensor and either Smartwatch 3, or LimiTTer could be used to provide realtime data via xDrip and Wireless Bridge
  • Android Phone
  • Any pump.

Your phone will need to be set up with the option to use APK files from any source, which can be found in Settings -> Security -> Unknown Sources

Set Up:

In order to set up HAPP with the Dexcom G5, you will require two pieces of software. xDrip with G5 support and HAPP.

xDrip with G5 support:



Questions can be asked at

If you plan to use Nightscout with these platforms, you’ll need to follow the instructions here:

You’ll also need some additional software on your phone, called nsclient, that will upload HAPP accepted treatments to your NightScout site. That can be found at: The installable is available at:

xDrip supports the Dexcom G4 with the xDrip Wireless Bridge, a piece of build it yourself hardware, but if you don’t want to start off with soldering, then the Dexcom G5 presents the simplest approach.

Closing The Loop

Once you’ve built and run HAPP for a while, it’s likely that you’ll want to do some form of closed loop and there are a few options for this. They are:

Loop – an Apple only framework and algorithm that runs on an iPhone, works with Legacy Medtronic Pumps, uses Dexcom Share or G5, or Medtronic CGM for glucose data and requires a RileyLink to communicate between the pump and phone. It requires xCode on a Mac to set up.

OpenAPS – a Linux only framework that runs on a portable Linux computer with an attached 900MHz radio device, works with legacy Medtronic pumps and uses either cloud NightScout, xDrip locally on a phone, Dexcom hardwired or Medtronic CGM for glucose data. It can be set up using a PC running Windows or Linux, or a Mac.

AndroidAPS – similar to HAPP, an Android only app that implements the OpenAPS algorithm and works with a DANA R – the first closed loop implementation on Android, that needs no additional hardware components, works with multiple CGM systems and requires Android Studio to set up on your PC or Mac of choice.

All of these systems are portable, but you still have the option of running OpenAPS on a Raspberry Pi, or indeed, any other Debian Linux based computer. My selection of pancreases is shown below:

From left to right: Edison with Explorer Board in Tic-Tac box; Rileylink for Loop; Edison with Explorer Board in specially designed case; Raspberry Pi with Ti Stick

All of these are a little more involved in getting set up and will require you to use command line interfaces or build an application in the the Mac or Android development tools.

Another comment I’d make in relation to this is that it’s worth, where possible, building something that you can take offline and not lose the ability to loop. This means, somehow, passing data to a local data storage device for the loop to retrieve. It is built into all the platforms now.

Before closing the loop, it’s worth reading through Dana Lewis’ observations about how you can safely close the loop.


OpenAPS, built by Ben West, Dana Lewis and Scott Leibrand, supports multiple legacy Medtronic Pumps and can be used with a number of different CGM systems. It now has automated set-up scripts that are as easy as 1, 2, 3, literally. You can cut and paste from the guide in to the terminal of choice and it is very easy.  The introduction of the Edison with Explorer board has made it extremely portable and it is now a truly portable system. Explorer boards can be purchased from Enhanced Radio Devices. Edison’s are now out of production by Intel, but are still available from some sources. Work is ongoing to identify an alternative.

OpenAPS Edison Rig in Tic-Tac box, next to the pump

The home of OpenAPS can be found at: where you can find a vast array of information that relates to the platform. Follow the “Getting started” link to take you into the documentation, or follow this link:

To make OpenAPS work, you’ll need some of:

  • Dexcom G4
  • Dexcom G5
  • Medtronic CGM systems
  • Libre sensor and either Smartwatch 3, or LimiTTer could be used to provide realtime data via xDrip and Wireless Bridge
  • a Raspberry Pi or Intel Edison based computer
  • a mobile phone
  • An appropriate Medtronic pump (see documentation) with Carelink stick
  • Texas C1111 Radio stick
  • A laptop or PC (Mac, Windows or Linux)
  • Explorer board

The set-up of choice for many people is now Explorer Board, Edison and choice of CGM, and a 2000mAh or 2500mAh LiPo battery.

With the Explorer Board, and a small 850mAh LiPo battery, it is possible to get the OpenAPS rig to almost the same size as the RileyLink, however, the battery life on a set-up like this is only around five hours, so the majority of people do not use it like this. I have found it useful when doing sports:

My preference is Edison with Explorer board with Dexcom G5. Using this results in a small device, your phone for use away from wifi, and that’s about it!

You can of course use a Pi, if for example you’re struggling to get hold of parts. If you’re doing so, you may want to look at the mmeowlink project which has successfully replaced the Carelink USB stick with a number of alternative radio options providing better reliability and range in the radio communications.

You’ll also need to follow the instructions to set up NightScout included in the documentation.

OpenAPS now effectively runs with two available algorithms. oref0 and oref1:

oref0 is the original algorithm, where the basic APS functionality is there and meal assist and insulin sensitivity adjustments that make living with it easy are also included. It also dynamically calculates the carbohydrate absorption of foods that it has been told about after eating. Most of the features can be accessed via NightScout commands that allow a flexible and easily run system.

oref1 introduces some more advanced functionality, including “Super Micro Bolus” (SMB), “Unannounced Meals” (UAM) and Pushover alerts.

  • SMB allows the algorithm to provide small boluses when enabled (and can be triggered by Carb entry, bolusing or a temporary target). The benefit of delivering a calculated insulin amount as a bolus is that it takes effect more quickly than using a safe TBR, therefore reducing the effects of carbs. SMB requires that Autotune is enabled.
  • UAM where the algorithm identifies that the changes in glucose levels are outside of expected ranges based on the data it has, and calculates what it thinks the carb load is, then provides insulin to manage this. This reduces the need for accurate carb counts, and in some cases, any carb counts.
  • Pushover alerts are simply notifications from oref1 to tell the user that the algorithm thinks it needs more insulin or carbs based on the changes it is observing and the information it has. This proves to be extremely useful when out and about!
  • Autotune runs nightly to look at the previous 24 hours of data and adjust basal rates throughout the day, to try and ensure that basal rates are optimised. It also adjusts ISF.

Dexcom (either G4 with xDrip Wireless Bridge or G5), can be connected with xDrip to communicate with the Edison over bluetooth giving a local data store and offline looping option that doesn’t require the internet.

It’s worth noting that OpenAPS still requires boluses to be administered using the pump.

Selectable insulin curves are currently in beta test. This will allow a user to select the traditional model that approximates insulin action that has been in OpenAPS for some time, or exponential curves that mimic the glycaemic clamp data for both the new ultra-rapid insulins and standard fast acting.

The Gitter Channel, where you can ask questions, is at:


Loop is an implementation of Loopkit, a framework created by Nate Racklyeft, that runs on an iPhone. It was built with the aim of reducing the amount to carry for APS implementations and thanks to Nate and Pete Schwamb’s ingenuity, built as a framework for others to implement their own algorithms. It uses the RileyLink hardware to communicate between BLE from the iPhone to the RF frequencies the Medtronic pumps use. Loop provides hybrid closed loop capabilities and includes the ability to determine and deliver a bolus.


Loop + RileyLink
Loop + RileyLink

What hardware do you need?

  • RileyLink
  • iPhone
  • Dexcom G5 (or G4 with Share) although G5 recommended
  • Mac
  • Medtronic Pump (as per OpenAPS)

Loop can be run with Dexcom G4 data via Share, if you are in the US, but it is best run with the Dexcom G5 directly to the phone, reducing what you need with you. It has a companion app on the Apple watch that allows carb entries and bolusing direct from the watch and can incorporate current blood glucose and time since last run in a complication.

As Loop writes all data to HealthKit and runs everything locally, it is essentially an offline system and doesn’t require the internet connection to function. Uploading to Nightscout for remote monitoring is fully integrated.

One important item to note is that you can run Loop in open loop mode, meaning that it doesn’t send treatment instructions to the pump, which can be a good way to get yourself started with it.

To build Loop you will require a Mac running OSX or MacOS and XCode. It can’t be built without this.

Loop can be found at:

Loop operates uses a different algorithm to OpenAPS. It adjusts insulin based on future predicted glucose levels and has a beautifully crafted user interface to display all this. It includes a feature called “Retrospective Correction” that offers a mechanism for taking into account and adapting to unexpected short term variation.

Loop’s carbohydrate absorption model has recently been updated. It uses estimates of carbohydrate absorption times (for which a default can be used) to determine required insulin action. The update includes a feature known as “Dynamic Carb Absorption” and a graphical interface to show this data. This model allows Loop to monitor and account for variation in the absorption of a meal and account for it in how insulin is delivered. This means that it is better at offsetting carbohydrate absorption with insulin, and people are seeing better results.

The base insulin curve model in Loop is based on the Scheiner curves, and work is ongoing to improve these estimates with exponential curves, and include curves for the newer ultra-rapid insulins.

The Gitter channel is at:

As mentioned previously, Loop runs in Loopkit, a framework that provides access to glucose data, Apple Healthkit and NightScout.


AndroidAPS is an implementation of the oref0 algorithm in a modular platform on Android. It can be found at and is similar in form to HAPP, using the same xDrip based GUI.

The Hardware and Software you’ll need:

  • PC (Mac, Windows or Linux) running Android Studio
  • Android Phone
  • Dexcom G5 and xDrip or G4 with xDrip + wireless bridge
  • Alternatively, the Libre sensor and either Smartwatch 3, or LimiTTer could be used to provide realtime data via xDrip and Wireless Bridge
  • Dana-R Pump (unless you build your own driver for Medtronic)

It was built specifically with the Dana-R pump in mind. It is constructed using a modular approach, so if you wanted to create a version of the platform for Medtronic pumps, you’d in theory just need to create the appropriate pump driver. AndroidAPS has an open loop mode, and it is recommended to use this when getting started with the system.

AndroidAPS Front Page
AndroidAPS Front Page

As can be seen from the screenshots, it implements most of the NightScout functionality within the app, providing a very fully featured tool set for those wishing to use it. Similarly to Loop, you can calculate and administer boluses from within AndroidAPS.

Work is very close to completion to allow the Roche Accuchek Combo to operate with AndroidAPS. Alpha testing is currently underway, and it will provide a much bigger pool of pumps to be used.

AndroidAPS also has selectable insulin curves to allow different insulins to be used with correct action and absorption profiles, and includes Autosens functionality. The oref1 functions in OpenAPS are also in development for AndroidAPS.

The Gitter channel is at:


As further options become available for looping, I’ll add them to this page. These are the ones that I believe have the widest number of participants currently using and building them. None of them can be created without a decent level of involvement and it is worth getting to know what they are doing as you set them up, so that you have a feel for what is happening when you don’t think it’s quite right.

If you’re struggling to decide which of these might suit you best, I’ve written a basic comparison of the systems at a physical level and an in depth comparison of the OpenAPS and Loop algorithms, based on my experiences of the two over the past few months. It may help you whittle down your choice.

If you’re a parent trying to decide which to use with your T1 kid, you may want to take a look at Katie Disimone’s blog, where she has compared Loop and OpenAPS from that perspective.

So pick the one you like the look of and has the best fit to your needs and happy looping!