Building your first OpenAPS loop represents a significant step toward automating insulin delivery using open-source technology. Developed by the diabetes community, the OpenAPS methodology leverages existing insulin pumps and continuous glucose monitors (CGMs) with a small computer, or rig, to create a safety-conscious hybrid closed-loop system. This guide provides a thorough walkthrough of the entire process, from understanding the core components to optimizing your system for daily life. Whether you are a seasoned technologist or a motivated individual managing diabetes, this guide is designed to give you the foundational knowledge to proceed with confidence and caution.

Understanding the OpenAPS Ecosystem

OpenAPS, which stands for Open Artificial Pancreas System, is a reference design and set of tools that enables individuals to build their own automated insulin delivery system. It operates by executing a safety-focused algorithm, typically oref0 or the newer oref1, which interprets CGM data and calculates insulin delivery adjustments. The system is not a complete product but a blueprint supported by a global community.

The core concept involves a continuous loop. Your CGM sends glucose readings to the rig. The rig runs the OpenAPS algorithm, which considers your current glucose, rate of change, insulin on board (IOB), and configured settings. Based on this analysis, the algorithm directs your insulin pump to either increase, decrease, or suspend basal insulin delivery. This cycle repeats every five minutes, providing dynamic adjustments that are far more responsive than standard pump therapy.

It is essential to understand that OpenAPS systems are hybrid closed loops. They require the user to announce meals and calibrate the CGM. The system excels at managing basal rates overnight and between meals, significantly reducing the burden of constant decision-making. The open-source nature means that the code is transparent, auditable, and continuously improved by a dedicated group of contributors. This transparency is a core safety feature, allowing anyone to inspect, verify, and suggest changes to the algorithm.

Essential Prerequisites: Hardware and Compatibility

Before you begin the software setup, you must gather the correct hardware. Compatibility is specific, and using unsupported devices will prevent the system from functioning. The OpenAPS community maintains up-to-date lists of compatible devices on the official OpenAPS website.

Choosing a Compatible Insulin Pump

The insulin pump is the actuator of the loop. It must be capable of receiving remote commands and delivering temporary basal rates. Historically, older Medtronic pumps are the most supported due to their robust communication protocols. Specifically, the following models are widely used:

  • Medtronic 512 / 712
  • Medtronic 515 / 715
  • Medtronic 522 / 722
  • Medtronic 523 / 723
  • Medtronic 554 / 754 (European models)
  • Medtronic 551 / 751

These pumps use the RF protocol that can be intercepted and initiated by the rig. Newer Medtronic pumps (600-series and 700-series) typically use encrypted Bluetooth and are not directly compatible with OpenAPS. It is important to source a suitable pump before proceeding.

Selecting Your Continuous Glucose Monitor (CGM)

The CGM provides the sensor data that drives the loop. The most commonly used CGM is the Dexcom G6 because it offers reliable accuracy and does not require fingerstick calibrations in its native mode. The Dexcom G7 is also supported but may require different setup steps. Some users repurpose the Abbott FreeStyle Libre using a bridge or transmitter like the MiaoMiao or Bubble, though this adds another layer of complexity. The system requires a steady stream of glucose data, so your CGM choice must be reliable and consistently paired with the rig.

Building or Buying Your Rig

The rig is the small computer that runs the algorithm. It needs to be powerful enough to process data quickly and power-efficient enough to run portably. Common options include:

  • Raspberry Pi Zero W: The most popular choice due to its low cost, small size, and built-in Wi-Fi and Bluetooth. It is powerful enough for oref0 but can be slower for oref1.
  • Raspberry Pi 3 or 4: More processing power, suitable for oref1, but larger and consumes more battery.
  • Intel Edison with an Explorer Board: A classic original rig design. The Explorer Board has a built-in radio chip, simplifying wireless communication. However, the Edison is now discontinued and harder to source.
  • Android Smartphone (AndroidAPS): While not strictly OpenAPS, AndroidAPS is based on the same oref0/oref1 algorithms. This guide focuses on the dedicated rig approach, but the principles are shared.

To communicate with the Medtronic pump, the rig requires a radio chip, typically the Texas Instruments CC1111 (often found on a USB dongle) or a TI Chronos watch. The Explorer Board integrates this chip directly. You will need to flash the CC1111 with the appropriate radio firmware (e.g., SubGhz_RFSPY) to enable the rig to talk to the pump.

Setting Up the Software Environment

With the hardware assembled, the next step is preparing the software environment on the rig. This process assumes you are comfortable with the Linux command line and basic network configuration.

Operating System and Initial Configuration

Start by flashing an operating system onto your SD card. Raspberry Pi OS Lite (the headless version) is a standard choice for Pi-based rigs. Use Raspberry Pi Imager or Balena Etcher to write the image. Before booting, configure the essential settings for headless operation:

  • Enable SSH by placing an empty file named `ssh` in the boot partition.
  • Configure Wi-Fi by creating a `wpa_supplicant.conf` file with your network credentials.
  • Ensure the timezone and locale are correctly set for your region, as the loop relies on accurate timestamps.

Insert the SD card into the Pi, power it on, and SSH into the device using its IP address (which you can find from your router's DHCP lease table). The default user is `pi` and the password is `raspberry`. Change the password immediately.

Installing Core Dependencies

Update the package manager and install the required tools. OpenAPS is built on Node.js, so you need to install it along with git.

Pro tip: Use the NodeSource repository to install a specific, stable version of Node.js that is recommended for your version of OpenAPS. Check the oref0 GitHub repository for the current requirements.

Install the following packages using `apt-get`:

  • git
  • nodejs (version 10.x or 12.x is generally stable for oref0)
  • npm
  • build-essential
  • libusb-1.0-0-dev

Verify the installations by running `node --version` and `npm --version`. Once the dependencies are in place, you are ready to clone and configure the OpenAPS software.

Installing and Configuring the OpenAPS Software

This is the most critical phase. The installation will create the myopenaps directory, which contains all the tools, settings, and data for your loop.

Cloning the Repository and Installing Tools

From your home directory, clone the oref0 repository:

git clone git://github.com/openaps/oref0.git

Navigate into the directory and run `npm install`. This will download and compile the necessary Node.js modules. Next, add the `oref0` directory to your system's PATH, or create symbolic links to the executables in `/usr/local/bin`. The standard approach uses the `openaps` tool to initialize your instance:

cd ~
openaps init myopenaps

This command creates the `myopenaps` folder structure. You will then populate it by running `openaps report add` commands for your specific pump and CGM setup. The community provides detailed scripts and vendor directories (e.g., `openaps-vendor- ExplorerBoard`) that automate much of this device detection.

Detailed Configuration of Preferences

The behavior of your loop is controlled by the preferences.json file located in your `myopenaps` directory. This file dictates how aggressive or conservative the algorithm behaves. Editing this file correctly is paramount for safety.

Critical Safety Parameters (max_iob, max_basal)

  • max_iob: This is the maximum total Insulin on Bolus (IOB) the system is allowed to accumulate. It includes both the IOB from your basal delivery and any boluses. A typical starting point for adults is between 2.0 and 5.0 units. Setting this too low can prevent the system from correcting high glucose effectively; setting it too high increases the risk of hypoglycemia. This must be set conservatively.
  • max_basal: The maximum temporary basal rate the pump is allowed to set. This is a multiple of your maximum scheduled basal rate. The default is often 2.0 (meaning the system can double your highest basal rate). For safety, keep this low initially, such as 1.5 or 2.0, and only increase if your pattern of highs requires stronger correction.
  • min_5m_carbimpact: This setting is used by the algorithm when carbohydrate absorption is uncertain. It represents the assumed default carb absorption rate per five-minute period. A typical default is 8. This setting affects how aggressively the algorithm responds after a meal.

Personalizing Your Targets and Ratios

  • target_bg: The glucose target for the loop. You can set a range (e.g., 100 to 120 mg/dL). The algorithm will work to keep you within this range.
  • insulin_sensitivity_factor (ISF): How much one unit of insulin lowers your blood glucose. This is used for correction doses. Getting this right is essential for accurate corrections.
  • carb_ratio: The grams of carbohydrates covered by one unit of insulin. This is primarily used for meal boluses, but it influences the algorithm's understanding of your physiology.
  • basal_profile: Your standard basal rates from your pump. The algorithm uses these as the foundation for its adjustments.

Safety Disclaimer: The OpenAPS system is a DIY medical device. It is not approved by the FDA or any similar regulatory body. Building and running this system requires a deep understanding of your diabetes and the technology you are using. You are solely responsible for your safety. Always have a backup plan, including access to manual injection supplies and the ability to revert to standard pump therapy. Consult with your healthcare provider before making changes to your therapy.

Launching and Testing the Loop

Before enabling the closed-loop function, you must thoroughly test the data flow and algorithm logic.

Dry Run and Simulation Modes

An OpenAPS setup can be run in open-loop mode, where the algorithm makes recommendations but does not automatically issue commands to the pump. This is the mandatory first step. Run the loop manually to see what it *would* have done. Review the `oref0-determine-basal` report outputs. Check the JSON files for logical consistency. Does the suggested temporary basal rate make sense given the current glucose and IOB? If the algorithm suggests suspending basal when glucose is 110 mg/dL and stable, that is good. If it suggests a strong correction when glucose is 70 mg/dL and trending down, something in your settings is wrong.

Run simulations using historical data. You can feed the loop past CGM and pump data to see how it would have reacted. This process helps you tune your ISF, carb ratio, and basal rates without any physical risk. Pay close attention to the system's behavior during fasting periods (overnight) as this is where the algorithm shines and where problems with basal rates are most visible.

The First 24 Hours of Closed-Loop Operation

Once you are confident in the open-loop recommendations, you can switch to closed-loop mode. This is done by enabling the loop to execute `oref0-loop` without the `--dry-run` flag. Stay awake and monitor the system closely during this initial period. Keep your fingerstick meter handy. Verify that the rig is receiving CGM data every 5 minutes and that the pump is responding correctly. It is common to make multiple small tweaks to preferences in the first few days. Do not leave the house unattended by your loop until you have observed several successful meal and fasting cycles.

Optimization: Autotune, Autosensitivity, and SMB

After you have a stable loop, the OpenAPS ecosystem offers advanced tools to refine your settings automatically.

Autotune is a tool that analyzes your historical data (glucose, insulin, carbs) to recommend adjustments to your basal rates, ISF, and carb ratio. It helps eliminate the guesswork from setting changes. Run `oref0-autotune` with your data to generate a report. Review these suggestions carefully before implementing them. Autotune is a powerful tool to gradually improve your time-in-range.

Autosensitivity is an algorithm feature that runs in the background. It detects patterns of unexpected highs or lows and temporarily adjusts the sensitivity of the system. If you are sick or resistant, Autosensitivity will make the loop more aggressive. If you are exercising and highly sensitive, it will back off. This is a key feature for maintaining control during variable conditions without manual intervention.

Super Micro Bolus (SMB) is an advanced feature available in oref1. Instead of only adjusting the basal rate, the system can issue tiny, frequent boluses to correct high glucose. This can lead to faster corrections and better post-meal control. However, it requires careful configuration of max_iob because SMB adds to IOB. Enable SMB only after you have a solid understanding of your standard loop's behavior.

Living with the Loop: Community, Safety, and Maintenance

Operating an OpenAPS loop is an ongoing commitment. The technology requires maintenance, monitoring, and continuous learning.

Troubleshooting Common Issues

Common problems include rig connectivity loss (Wi-Fi drops), radio communication errors (pump too far away), and battery depletion. Develop a routine for checking your rig's status. Many users set up a nightstand charger for the rig. Learn to read the log files in `~/myopenaps/log`. If the loop fails to execute, the logs will tell you why. Common fixes involve resetting the radio hat, power cycling the rig, or re-pairing the pump.

The Importance of Community Support

You are not alone. The OpenAPS community is active, knowledgeable, and welcoming. The OpenAPS Community Page connects you to forums, Slack channels, and local meetups. If you encounter a configuration issue or have a question about a specific setting, the community is an invaluable resource. They have debugged almost every possible problem and can offer guidance. Participating in the community is also a way to contribute back, helping others on their journey.

Maintain a rigorous safety mindset. Always carry a backup insulin pen or syringe. Have a plan for what you will do if the rig fails or the CGM disconnects. Regularly update your software to get the latest safety checks and features. Test changes to your preferences in a controlled environment before trusting them fully.

Conclusion

Building your first OpenAPS loop is a substantial project that demands attention to detail, a willingness to learn, and a strong sense of personal responsibility. The reward is a highly personalized system that can reduce the daily burden of diabetes management, improve time-in-range, and provide peace of mind. By following the steps in this guide, understanding the underlying algorithms, and leaning on the community, you can successfully build and operate a safe and effective loop. The journey from manual management to automated assistance is transformative, giving you back time and mental energy.