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 two apps that support Open Loop out of the box. HAPP and Loop. As HAPP is only Open Loop and doesn’t need to talk to a pump for data, I’ve covered that here. Loop 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 and requires a RileyLink to communicate between the pump and phone. It requires xCode on a Mac to set up.

OpenAPS – a Linux based framework that runs on a portable Linux computer, works with legacy Medtronic pumps and uses either cloud NightScout, local NightScout, xDrip locally on a phone, Dexcom hardwired or Medtronic CGM for glucose data.

AndroidAPS – similar to HAPP, an Android app that works with a DANA R – the first closed loop implementation on Android.

All of these systems are now 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 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.

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
  • A laptop or PC (Mac, Windows or Linux)
  • Explorer board, which brings the overall size of an Edison solution in line with the Loop RileyLink component.

The set-up of choice for many people is now Explorer Board, Edison and choice of CGM. With the Explorer Board, and a small 850mAh LiPo battery, it is possible to get the OpenAPS rig to the same size as the RileyLink:

To really reduce the footprint of the OpenAPS setup, my preference is Edison with Explorer board with Dexcom G5. Using this (and assuming you have an Android phone) results in a very small device, your phone, 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 has seen the development of some more advanced features such as meal assist and insulin sensitivity adjustments that make living with it easy. It also 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.  The most recent development, a series of set-up scripts for the platform, have made installation a great deal easier. The details for these are included in the documentation link.

It is now possible to connect a Dexcom (either G4 with xDrip Wireless Bridge or G5), 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 very effective.

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 + 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 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, although it does to upload to Nightscout.

One important item to note is that you can run Loop in Open Loop mode, meaning that it doesn’t need to interact with the pump to deliver treatment, 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 slightly differently to OpenAPS in that it needs to be told about carbohydrate absorption times. It has a feature called “Retrospective Correction” that seems to offer a halfway house between the OpenAPS features AMA and it’s lookback component to check that the predicted blood glucose matches what is happening. The experience of many using it is that while it is more convenient to carry, it requires a little more tuning.

The Gitter channel is at:

As mentioned previously, Loop runs in Loopkit, a framework that provides access to Dexcom data, Apple Healthkit and NightScout, and an effort is under way to try and port the oref0 dosing algorithm to Loopkit as a result.


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
  • NSClient
  • Dana-R Pump (unless you build your own driver for Medtronic)
  • RileyLink

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 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.

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!