Skip to content

Instantly share code, notes, and snippets.

Last active Feb 29, 2020
What would you like to do?
Loop for offline OpenAPS

Using Loop for offline OpenAPS

Loop is an iOS "app template for building an automated insulin delivery system". Included in Loop is xDripG5, which runs alongside the Dexcom iOS app and intercepts the BLE glucose messages for local use.

These instructions describe how to use Loop as a glucose data source for offline looping using OpenAPS. Note that most of the features of Loop itself (closed loop algorithm, insulin dosing) are not used in this modification; we are using Loop simply as a local bridge for glucose data from the G5 transmitter to the OpenAPS rig. If you have a working version of Loop already installed, it is recommended build this branch as a separate app by using a unique bundle identifier.


  1. Build (and deploy to your iPhone) a version of Loop using the lookout branch from @thebookins. Follow the instructions in Loop Docs but install Loop as follows:
git clone
git checkout lookout

(alternatively, merge the lookout changes with your own Loop fork). Depending on the version of XCode you are using, it may be necessary to rebuild the linked frameworks using carthage:

carthage update --platform iOS
  1. If you haven't already done so, install the dev branch of OpenAPS using the setup script with xdrip as the glucose source.

  2. Step 2 will set up xDripAPS on your OpenAPS rig. This is a Python program that exposes a very simplified NightScout instance running on the rig to which we can send glucose data. A couple of changes to xDripAPS are required to get it to accept glucose data from Loop. Pull these changes as follows:

rm -r .xDripAPS
git clone $HOME/.xDripAPS
cd .xDripAPS
git checkout lookout
  1. Setup up Bluetooth tethering between your iPhone and your OpenAPS rig.

  2. Open Loop and the Dexcom app on your iPhone. The Dexcom app will control the G5 transmitter; Loop just listens in.


  1. In Loop, select G5 Transmitter in Settings and enter the G5 Transmitter ID. Do not add the pump serial number as we are using Loop only as a local bridge to get BG data to OpenAPS. (Without a RileyLink, it's impossible to control the pump anyway.)

  2. In Loop, select Nightscout in Settings and enter the local URL for your edison. This will be something like Enter your API secret.

All done. Loop will now send glucose data to the edison URL every five minutes, ready to be picked up by oref0.

Copy link

rainbow-lazer commented Aug 26, 2018

This is fantastic! Is there an easy way to determine your local NS url? I gather this is not the same as the Bluetooth IP address that the phone would assign, correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment