Skip to content

Feature: Using Nightscout as CGM data source #1134

Closed

Description

@Andrei0105

Some CGMs don't support connecting to Loop and the easiest way to do this is to upload their data to Nightscout and retrieve it from there.
This was already discussed in #84, but this does not consider CGMs that are not compatible with xDrip+.
It also seems that this was possible in Loop v1.4.0 (#535, #492) but it's not possible currently.

I created a pull request (LoopKit/dexcom-share-client-swift#9) in https://github.com/LoopKit/dexcom-share-client-swift that allows the user to use his own Dexcom share server. This can be used with https://github.com/dabear/NightscoutShareServer to retrieve data from Nightscout.

How to use this feature as of now:

  • Set up a Nightscout site for your CGM
  • Follow the instructions in https://github.com/dabear/NightscoutShareServer to set up a Nightscout Share Server
    NOTE: NightscoutShareServer is no longer supported by the original author. You can get the last working version from here: https://github.com/Andrei0105/NightscoutShareServer, but this is not currently being maintained (although I plan to in the future).
  • Fork https://github.com/Andrei0105/dexcom-share-client-swift https://github.com/LoopKit/dexcom-share-client-swift and follow the instructions in ShareClient/ShareClient.swift: uncomment line 44 in ShareClient/ShareClient.swift, add the URL of your Nightscout share server and uncomment lines 34 and 35 in ShareClientUI/ShareService+UI.swift
  • Fork both https://github.com/LoopKit/G4ShareSpy and https://github.com/LoopKit/CGMBLEKit
  • In both the above repositories update the Cartfile the following way: change github "LoopKit/dexcom-share-client-swift" ~> 1.2 to github "yourgithubusername/dexcom-share-client-swift" "master", where yourgithubusername is the username of the github user you used to fork the repos
  • Delete the Cartfile.resolved files
  • Back in the Loop folder, in the Cartfile change the lines github "LoopKit/CGMBLEKit" ~> 3.2 and github "LoopKit/G4ShareSpy" ~> 1.1 to github "yourgithubusername/CGMBLEKit" "master" and github "yourgithubusername/G4ShareSpy" "master"
  • Also change the line github "LoopKit/dexcom-share-client-swift" == 1.2 in Cartfile to github "yourgithubusername/dexcom-share-client-swift" "master"
  • Delete the Cartfile.resolved file from the Loop folder
  • Build the Loop app. Now the option to select a custom share server should appear in Add CGM -> Dexcom Share

What is this useful for:
I have the Medtronic Guardian Connect standalone CGM which connects directly to my iPhone and data is retrieved from the Carelink portal and uploaded to Nightscout. The CGM can't be connected in any other way so this is the only solution to use it with Loop. I'm assuming there are more systems that can be used this way.

Activity

  1. Kdisimone commented on Oct 14, 2019

    @Kdisimone
    Collaborator

    #84 duplicate

  2. miriamkw commented on Jan 19, 2020

    @miriamkw

    Hello! I have followed this guide through, but every time i try to build Loop after I made the changes to the Cartfile, the Cartfile automatically resets the changes I have done. You know why this is?

  3. Andrei0105 commented on Jan 20, 2020

    @Andrei0105
    Author

    Hello! I have followed this guide through, but every time i try to build Loop after I made the changes to the Cartfile, the Cartfile automatically resets the changes I have done. You know why this is?

    Hi! Can you please post the contents of the cartfile before you edit and after you edit it. Also, are you using the master branch?
    Are you sure that you are updating Cartfile and not Cartfile.resolved? Can you delete Cartfile.resolved, update Cartfile, and try to build again?

  4. miriamkw commented on Jan 20, 2020

    @miriamkw

    Hi! Can you please post the contents of the cartfile before you edit and after you edit it. Also, are you using the master branch?
    Are you sure that you are updating Cartfile and not Cartfile.resolved? Can you delete Cartfile.resolved, update Cartfile, and try to build again?

    1: I find two Cartfiles with the line from the guide. One in Carthage⁩/Checkouts⁩/G4ShareSpy and one in Carthage⁩/Checkouts⁩/CGMBLEKit. They are identical, and I change both of them. Before:

    github "LoopKit/LoopKit" ~> 3.0
    github "LoopKit/dexcom-share-client-swift" ~> 1.2

    After:
    github "LoopKit/LoopKit" ~> 3.0
    github "miriamkw/dexcom-share-client-swift" "master"

    2: I am not in any branch because i downloaded the source code locally to my computer from Loopdocs: https://loopkit.github.io/loopdocs/build/step13/.

    3: Tried to delete Cartfile.resolved and build but the same happened.

    Thank you so much for answering so quickly!

  5. Andrei0105 commented on Jan 20, 2020

    @Andrei0105
    Author
    1. When you downloaded the source code did you choose Loop: Master branch or Loop: Dev branch? I didn't test this on Dev, so you should download Loop: Master.
    2. You are not editing the right Cartfile. The Cartfile you should be editing is located at the top level of the source directory you downloaded. Pictured below:
      loop1
      Since a new version of dexcom-share-client was released, the line you should be changing now is github "LoopKit/dexcom-share-client-swift" ~> 1.2.
      After this you should delete Cartfile.resolved (from the same directory where the Cartfile you edited is located), and build again.
    3. To check that your changes were applied look at the Cartfile.resolved contents after the build. You should have a line like this:
      github "miriamkw/dexcom-share-client-swift" "[some hash]"

    Please try this, and if you still have problems paste your Cartfile.resolved (the one generated after the build) here.

  6. miriamkw commented on Jan 20, 2020

    @miriamkw

    The version I had downloaded was Loop-master, but to me the Cartfile in the root didn't contain the mentioned line. So I cloned the project from Git instead, and edited the Cartfile.

    When I built it the changes stayed, but the Cartfile.resolved remained the same. Deleting the Cartfile.resolved before building solved the problem.

    Now my problem is that my Glucose levels do not start appearing in my Loop app. The username and password should not matter, right? I have already

    • checked that my integration against nightscout is working (from my NightscoutShareServer)
    • verified that I have made the changes to the forked dexcom-share-client-swift
    • verified that I chose the "custom" from CGM --> Dexcom Share in the app

    Can the problem be that in my branch of dexcom-share-client-swift I made the changes directly in Github? It says that "CompareThis branch is 2 commits ahead of Andrei0105:master". Do I have to clone the repository and push the changes?

  7. Andrei0105 commented on Jan 20, 2020

    @Andrei0105
    Author

    I checked your branch and it seems fine. You are right that the username and password don't matter. It usually takes 5-10 minutes for the first glucose values to appear.
    Did you tap Add account before tapping Save when you have to add a Dexcom Share account in Loop? If you don't click Add account then your credentials will be saved and it will look like everything is set up correctly but actually the account is not enabled in Loop.
    If after you click Add account you don't get any error it means that Loop connected successfully to your Share Server.

  8. miki3421 commented on Jan 20, 2020

    @miki3421

    I have the same problem, I did everything but in the heroku logs i'm not receiving calls to the webserver. UI is perfect and without errors. The only way that is found to receive only one call is:
    try to configure a Dexcom Webserver US for example and after try again the custom. In that case I can see in the log the Authentication request and the first Glucose request, but nothing else after. Even if i'm leaving running hours this configuration. Thanks

  9. miriamkw commented on Jan 20, 2020

    @miriamkw

    Even when I added account like you illustrated @Andrei0105 , it still didn't work. But now suddenly the option "Custom" disappeared again. I have tried restart the computer, update xCode, clean and build but nothing works. Now I suspect all my errors appear because I have the same project in several repositories.

    Will update when i figure out more. Thank you so much for the help so far.

  10. Andrei0105 commented on Jan 21, 2020

    @Andrei0105
    Author

    Hi! I don't think the problem is from your shareserver since it seems to be working fine. If the following solution does not work, I can test with your URL and see if the shareserver works properly.

    Now, to try another solution:

    • Fork both https://github.com/LoopKit/G4ShareSpy and https://github.com/LoopKit/CGMBLEKit
    • Perform the same change to the Cartfiles as you did for the Cartfile in the Loop folder (change github "LoopKit/dexcom-share-client-swift" ~> 1.2 to github "miriamkw/dexcom-share-client-swift" "master")
    • Delete the Cartfile.resolved files
    • Back in the Loop folder, in the Cartfile change the lines github "LoopKit/CGMBLEKit" ~> 3.2 and github "LoopKit/G4ShareSpy" ~> 1.1 to github "miriamkw/CGMBLEKit" "master" and github "miriamkw/G4ShareSpy" "master"

    Then build the application. To check that the changes have been applied, check Cartfile.resolved. The line github "LoopKit/dexcom-share-client-swift" "v1.2" should no longer be in there.

  11. miriamkw commented on Jan 21, 2020

    @miriamkw

    Update:
    It is finally working, since 5 minutes ago! I am not completely sure what made it work, but after I added the insulin pump, I deleted the CGM and added it all over again, and it started working.

    Checklist for people that might meet the same problem:

    • Be sure you have Bluetooth on
    • Be sure Nightscout is having connection with your sensor
    • I use Tomato app, and this has to be running on the iPhone
    • And of course, this system requires that you have an Internet-connection

    I am greatful for this solution, as this is my only opportunity to be able to Loop (Freestyle Libre 2 x Omnipod x iPhone). Thank you again!!

  12. Andrei0105 commented on Jan 21, 2020

    @Andrei0105
    Author

    Great! I'm happy it's finally working.
    With the Freestyle Libre I think you can use Spike and this will not need an internet connection (I'm not sure but I'll switch to the Libre in less than 2 weeks and I was hoping to not need internet anymore).

    As a sidenote: If you have both Nightscout and ShareServer running on the same Heroku account you will probably exceed the 1000 free dyno hours per month. You can run the ShareServer in Azure and thus avoid having to pay for a dyno in Heroku. The ShareServer has a Deploy to Azure option which makes setting it up very easy.

  13. miriamkw commented on Jan 21, 2020

    @miriamkw

    Spike does not yet support Freestyle Libre 2, so if you have the opportunity I would recommend Libre 1. I hope it will be available for Libre 2 soon, though.

    Oh, I did not notice this limit. I ran into trouble with the setup of Azure but I will try again. Thanks!

  14. miki3421 commented on Jan 21, 2020

    @miki3421

    Thanks @miriamkw .
    i think mine is not working because i'm using the simulator as a Pump.
    i can't connect the Omnipod so i'm using "manually"
    @Andrei0105 do you think can be this the case for my issue?
    Thanks

  15. miriamkw commented on Jan 21, 2020

    @miriamkw

    Thanks @miriamkw .
    i think mine is not working because i'm using the simulator as a Pump.
    i can't connect the Omnipod so i'm using "manually"

    Maybe try to go to Settings --> Loop and give Loop app access to Bluetooth?

    I cannot understand that the CGM is dependent on being connected to a real insulin pump. But when I connected to the OmniPod Loop asked me for the access to BlueTooth, so that might have made the difference?

  16. 22 remaining items

  17. cyoung1024 commented on May 22, 2020

    @cyoung1024

    @shortanu it's imperative not to use Health with Spike. Spike cannot have access to Health in any capacity not only for Loop to function properly, but more importantly to avoid double carb entries. If Spike has access to Health, you could end up having double the carbs, and therefore be given double the insulin. Furthermore, using Health as your CGM data source would require your phone to be open (screen on, phone unlocked) constantly, as apps do you have access to Health while turned off. This would mean that the minute you lock your phone, Loop stops looping. Therefore your current method is not viable. Your options are either to use this method and have Nightscout as your data source, or to use a Spike branch and have Spike in follower mode as your data source.

  18. shortanu commented on May 22, 2020

    @shortanu

    @cyoung1024 thanks for details, those are the options or switch to Dexcom as I self-fund fully ;) but would like to get best out of remaining GC and test-drive Loop early to get accustomed as I was already using Spike in follower mode for carbs and insulin input to Nightscout.
    At the moment I am manually adding injected boluses and carbs in Spike so is the only app writing in Health, thanks to your comment I realised that an improvement I can make is to start entering carbs in Loop to get used with the UX if Loop will push entries to Nightscout.

    To get back on this topic, somehow Loop was getting Glucose values even before me adding any CGM source in the app, so I wondered if it's because of Spike usage as I have internal HTTP on and if building Loop with Spike branch would have major added value.
    IMG_2803
    IMG_2804
    IMG_2805

    @Andrei0105 is Loop always showing that yellow ! for glucose by using this method or something is wrong on my side?

    cheers, the journey to Loop is exciting

  19. Andrei0105 commented on May 22, 2020

    @Andrei0105
    Author

    @shortanu As @cyoung1024 said, you are currently getting values in Loop from Health. Loop reads the data the Spike is uploading there. This does not work when the phone is locked.

    Yes, you can add carbs in Loop, but I don't think this will be very useful to you now as you will not see any predictions without both the pump and cgm added. You can try with the simulator pump, I haven't used that so I'm not sure how it works.

    As @cyoung1024 said, you have 2 options, either build Loop with this change, or use Loop with Spike and get data from Spike's internal HTTP server that Spike will read from your nightscout site via follower mode.

    If you use this method, you will need in addition to you nightscout site, the nightscout share server (which you should host in Azure to avoid reaching your free limit in Heroku). It's more difficult than just installing Loop with Spike support, but it has one advantage: you won't depend on Spike. As much as I like Spike and I'm using it now, there are moments when I have to restart my phone because the HTTP server just won't work.

    Installing Loop with Spike is simple, and if Spike is working well for you this is what I recommend.

    You also have a third option: using this change with Loop with Spike. If you apply the method described here to a Loop with Spike branch you'll get a version of Loop with both Spike and custom shareserver support. Thus, if you want to change from one to another you just have to change the CGM.

    For the yellow !, did you add the CGM or is Loop reading the health data? If you added a CGM and you get data consistently you shouldn't worry about that.

  20. shortanu commented on May 23, 2020

    @shortanu

    ok then, I didn't understood it right when @cyoung1024 (sorry about that Caroline) mentioned it but now it makes sense.
    Indeed, it was reading BG data written by Spike in Health. Tested by disabling Spike share to Health and confirmed. This is also reason behind the yellow !, it indicates inconsistent CGM data flow as mentioned in LoopDocs "If the yellow alert remains, something may be wrong with fetching BG data."
    Now I've done a build of Spike master branch and works, Loop writing in Health now.
    @Andrei0105 nice idea with 3rd option, will stay in my head and probably do it in the end :)
    Until then, as I'm not yet pumping, the Spike version suits me better, but have some doubts about the long run as I saw my phone struggling with Spike at heavy use moments.

    thanks 🙏

  21. liamzebedee commented on Jul 24, 2020

    @liamzebedee

    For those that come across this thread, I had difficulties getting NightScoutShareServer running using the Dockerfile due to the dotnet dependency, and reimplemented it a bit more simply in Node.js - https://github.com/liamzebedee/nightscout-share-server-node.

    Cheers to @Andrei0105, I managed to get my Loop running thanks to this fork!

  22. lukebandy commented on Jan 2, 2021

    @lukebandy

    Hey @Andrei0105, thanks for the work on this. I had this working with Loop v2.2.2 and Xcode 12.0.0, but following the same steps with Loop v2.2.4 and Xcode 12.3 seems to produce various 'in scope'/'type does not conform' errors. Have you had much luck, or is it likely that I've made a mistake?

  23. sp90 commented on Feb 19, 2021

    @sp90

    @lukebandy @Andrei0105 I have the same issue upgraded to Xcode 12.4, Loop 2.2.4, iOS 14.4 & macOS 11.2.1. Now I cannot get my spike data to loop which is kinda hard when I really need this to work

  24. Andrei0105 commented on Feb 19, 2021

    @Andrei0105
    Author

    @lukebandy @sp90 Hi, please try one of newer alternatives to get Nightscout data into Loop:

    @sp90 If you are using Spike to read data from your CGM you can also use either FreeAPS or one of the Spike branches and get data directly from Spike, without having to upload it to Nightscout

  25. sp90 commented on Feb 19, 2021

    @sp90

    @Andrei0105 do you have a link to a spike branch that works with the latest and greatest

    Xcode 12.4, Loop 2.2.4, iOS 14.4 & macOS 11.2.1
    

    I have taken the @cyoung1024 Loop branch that worked in the past, then I have pulled the current loop master branch onto it "no conflicts" and are now building to my phone to see the result

  26. Andrei0105 commented on Feb 19, 2021

    @Andrei0105
    Author

    @sp90 spike-master and spike-autobolus from the link I posted are up to date with Loop master and automatic-bolus. Cal is no longer maintaining the spike branches, and the up to date ones are the ones I posted which are maintained by me and should work without any issues with the latest versions of Xcode and iOS since they're based on the latest version of Loop.

  27. sp90 commented on Feb 19, 2021

    @sp90

    @Andrei0105 THANKS!! I will give it a shot - It works!

  28. github-actions commented on Oct 22, 2023

    @github-actions

    This issue is stale because it has been open for 30 days with no activity.

  29. github-actions commented on Nov 5, 2023

    @github-actions

    This issue was closed because it has been inactive for 14 days since being marked as stale.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions