image frame


A developers prospective on DIY APS and #WeAreNotWaiting

Automation, use it wisely

AndroidAPS Automation

Automation is relatively recent addition to AndroidAPS.
It came to fruition in AndroidAPS v2.5 and since then we have seen some great examples on how it can be used. Gaining further control and guidance the APS system in certain situations.

If you are considering to use it, be aware of the following caveats:

  • Profile switching renders Autosens useless for a min of 6 hours.

  • Profile switching will not reset the profile back to your base profile (you have to make another rule to set this back or do it manually).

  • Increased risk of Hypoglycemia if profile switch does not expire or reset back to base profile.

Some Notes to how Autosens works:

  • Autosens is a algorithm which looks at Blood Glucose Deviations (Positive/Negative/Neutral. It will try and figure out how sensitive/resistant you are based on these deviations.

  • The oref implementation in OpenAPS runs off a combination of 24 and 8 hours worth of data. It uses either one which is more sensitive.

  • AndroidAPS only runs off 8 (to enable UAM) or 24 hour as a user option.

  • Changing a cannula or changing a profile will reset Autosens ratio back to 0%.

  • Autosens adjusts your basal and ISF for you (ie: mimicking what a Profile shift does).

  • if continuously eating carbs over an extended period, autosens will be less effective during that period. (Carbs are excluded from BG delta calculations)

So some basic guidelines:

1) Make sure Profile switches are made sparingly and preferably at a last resort. Profile switches should have a reset condition so the profile can return to normal again to minimize risk of hypoglycemia.

2) Try not make conditions too easy (for example: if bg > 80 mgdl and bg < 180mgdl) ) doubly important if the action is a profile switch*

3) Try and use Temp Targets instead of Profile Switches. Temp Targets do not reset Autosens back to 0.

Moving into developing AndroidAPS versions 2.6 to 2.7 we will bring the Autosens to more closely follow the Openaps implementation.

Watch this space and enjoy automation!

APS, you and your cell phone

To those who have experienced looping on a smartphone, the experience is fantastic is it not? Carrying around a device that can also double as your artificial pancreas, makes so much sense.

We have started seeing an overwhelming push from smartphone manufacturers to make sure that your battery lasts as long as long as it can.

iOS and Android versions from 8+ will now proactively sleep apps that sip battery and have background processes running.

This is great for most people, as they get more battery life and who doesn’t want that eh? But what about the people who use a smartphone as medical device? What about us “Loopers”?

This is where it can get complex, and this is where most looping setups will fail, it all comes down to CGM data collection.

In particular CGM Bluetooth devices that spend most of the time ‘sleeping’.

On the Dexcom CGM system, the transmitter stays awake for less than 15 seconds every 5 minutes. Then during that window your phone will try to connect to your transmitter, open the connection up, provide a reading and then close the connection.

These small windows of opportunity to get CGM data are consistent and there is no way to make these windows bigger without sacrificing battery life on the transmitter itself. Any small hiccup in the chain can stop a cellphone from getting a CGM reading, so developers will always try and make sure the code executes to connect and get the reading done in time. Not all phones are equal and setting on each phone are not equal either.

The most common setting which prevents CGM collection is battery saving, it does this by a combination of factors, sleeping sections of hardware on the phone that are not used (ie: Bluetooth), and sleeping processes that run in the background. In some cases when the hardware has been slept by the above manner it can take setting a fake alarm to wake the hardware up in a timely manner!

How do make sure battery saving is turned off?


Settings > Battery > Standby intelligent power saving = off

Settings > Battery > Adaptive Battery = off

Some Android Phones will have some other battery saving settings, turn those off.

In AndroidAPS and xDrip, the apps are whitelisted from stock Android Battery Saving, but this will not stop other battery saving applications from sleeping them.

Ensure that all other battery saving tech is turned off, esp if running a Huawei/Oppo/Honor/Xiaomi phone.


iOS with the Dexcom App and Loop should run fine on a tested/supported version of iOS. Do not enable Low-Power Mode or turn off Bluetooth while using your phone.

So what phones are best to collect CGM data on?


Any Android One handset (or Android at stock); Manfucturers such as Nokia, Motorola’s One devision and Google’s Pixel.


Any iPhone should be suitable for CGM collection.

If you loop with a smartphone, you should treat your phone as a medical device.

What do I mean by that? Be cautious before proceeding with anything that is making changes to your phone, installing apps, software updates etc. The last thing you want is a broken loop!

Operating system updates can break your loop so, check on social media, github issues etc for postings about new updates etc. Also keep your CGM/APS apps up to date.

Hope this helps.

  • © 2019-2020 Tim Gunn

Buy me a cup of coffee