As the scripts and methods evolve (and they will), I'll endeavour to keep this page up-to-date. Whilst, I'll do my best to respond to questions here or via Facebook or Twitter, please keep in mind that I have a little PWD, a lovely wife and a day job, all of whom require some tlc from time to time...
Is this for me?
Aim: Outline what you would need to implement this solution
If you haven't done so already, please read through my earlier posts on what's been achieved before going any further. The one to start with is probably this one.
You'll need
- a Medtronic 640g with Enlite CGM
- a Bayer Contour Next Link 2.4 BG meter (preferably your backup meter)
- a computer / tablet running Windows 7/8.1/10
- patience whilst you deal with CareLink and some hasty coding from me that bolts the 640g on to Nightscout.
There's a lot more work to do, both on testing and adding more functionality, including developing a solution that delivers a completely mobile solution (some ideas on their way there...)
This is not an official Nightscout plugin or extension. However, the same level of caution should be exercised as per the standard Nightscout disclaimer:
All information, thought, and code described here is intended for informational and educational purposes only. Use of code from github.com is without warranty or support of any kind.
Each element of the system can fail at any time rendering the system unusable. There is no password protected privacy or security provided by these tools; all data you upload can be available for anyone on the Internet to read if they have your specific URL to view your data.
Do not use any of this information or code to make medical decisions.
In addition, every time you upload to CareLink your CareLink DB (and CSV file if you use that elsewhere) becomes bloated by ~180 lines of summary information: that quickly mounts up. The long term impact of that on your CareLink data is unknown.
Ready? Let's go...
This is not an official Nightscout plugin or extension. However, the same level of caution should be exercised as per the standard Nightscout disclaimer:
All information, thought, and code described here is intended for informational and educational purposes only. Use of code from github.com is without warranty or support of any kind.
Each element of the system can fail at any time rendering the system unusable. There is no password protected privacy or security provided by these tools; all data you upload can be available for anyone on the Internet to read if they have your specific URL to view your data.
Do not use any of this information or code to make medical decisions.
In addition, every time you upload to CareLink your CareLink DB (and CSV file if you use that elsewhere) becomes bloated by ~180 lines of summary information: that quickly mounts up. The long term impact of that on your CareLink data is unknown.
Ready? Let's go...
Aim: Get Nightscout website and associated database working
Carefully follow all the instructions set out in the setup wiki hosted by Nightscout here.
By the end of the setup process, we have the following up and running
- Mongo DB, with a unique DB name, user and password set
- Github to fork the main Nightscout CGM Remote Monitor
- Azure website account and website setup, including:
- Linked to Github fork of CGM Remote Monitor
- Correct connection strings, which must include the following names:
- mongo
- mongo_collection
- API_SECRET
- enable [for the plugins]
No need to enter the Dexcom settings.
No need to enable the Medtronic Connect plugin
No need to enable the Medtronic Connect plugin
Setup CareLink
Aim: Get CareLink all set
Make sure everything works manually and is set to mg/dL*
* From version 0.75 onward, there's no need to change units in CareLink
Follow Medtronic's instructions precisely when first attempting a pump upload.
Make sure you can manually upload data from the pump to CareLink.
Make sure you can manually select a CSV Report and download it.
Make sure you can manually upload data from the pump to CareLink.
Make sure you can manually select a CSV Report and download it.
Grab the mmcsv640g repo
Aim: Get the scripts you need to make this all work...
Fork / Download a copy of https://github.com/LittleDMatt/mmcsv/tree/mmcsv640g
Download and install nodejs
Download and install GitHub for Windows.
The following isn't working for all users...
[Within GitHub for Windows, under Tools and Options, Options, select Git Bash Shell as your default Git Shell. Open Git Bash Shell (from within GitHub for windows or from the Git Shell link probably created in your Start Menu]
My suggestion is to try this instead...
[Download Git SGM via https://git-for-windows.github.io/
Install, accepting all defaults until you get to select terminal emulator: Select
Use Windows' default Console Window
Complete the installation and close the installer.
Open your new terminal: All Programs, Git, Git Bash
]
Change to the directory where you've downloaded mmcsv640g, e.g. by typing:
cd /c/users/matt/nightscout/mmcsv
(NB forward slash and /c/...... to get things going in the bash shell)
Type:
npm install
The following isn't working for all users...
[Within GitHub for Windows, under Tools and Options, Options, select Git Bash Shell as your default Git Shell. Open Git Bash Shell (from within GitHub for windows or from the Git Shell link probably created in your Start Menu]
My suggestion is to try this instead...
[Download Git SGM via https://git-for-windows.github.io/
Install, accepting all defaults until you get to select terminal emulator: Select
Use Windows' default Console Window
Complete the installation and close the installer.
Open your new terminal: All Programs, Git, Git Bash
]
Change to the directory where you've downloaded mmcsv640g, e.g. by typing:
cd /c/users/matt/nightscout/mmcsv
(NB forward slash and /c/...... to get things going in the bash shell)
Type:
npm install
If you get an error along the lines of can't find npm or nodejs, type:
export PATH=$PATH:'/c/Program Files/nodejs'
You might get a couple of lines of grumbling / advisories, but you shouldn't get a stream of warnings or errors.
Pump to CareLink -- CareLink to PC -- Nightscout
Aim: To automatically deal with the CareLink website to request a regular data upload from the pump and then download a CSV report
You'll need to be running Windows (7,8 or 10)
Please install Firefox and Selenium IDE
In your Firefox tab, the Selenium IDE icon is on the far right (under the maximise window icon):
An example script is provided in the repo here.
To use the script, in your download (NOT up on GitHub) change YOURUSERNAME and YOURPASSWORD to your CareLink username and password.
These only get used and sent to CareLink - they are not sent or stored elsewhere
Under Options, Schedule tests to run periodically, select every, say 10 minutes and save your Test Suite under the File menu.
Thanks to the Java plugin used by Medtronic to upload from the pump, getting interaction recorded within the Java-enabled window needed some brute-force mouse clicking... For this, mmcsv640g uses a small, but very flexible mouse (and keyboard) macro builder by the name of Mini Mouse Macro. Download the free version and make sure it runs from a suitable location (e.g. /c/users/matt/nightscout).
Final Tweaks
Aim: Get local CSV file, with the Sensor Glucose values and other pump information, up to Nightscout
In your downloaded copy of mmcsv640g, copy the config.sh file and paste it somewhere safe
(e.g. /c/users/matt/nightscout)
Open it up in a text editor and pop in your local setup variables - hopefully the comments after each explain what we're after:
Mmcsv640gPath='/c/Users/matt/Nightscout/csv/mmcsv' #Installation Directory for mmscv640g stack
CSVDataPath='/c/Users/matt/AutoCSV' # The directory you want to throw all the data around in
DownloadPath='/c/Users/matt/Downloads' # Where your CSV file downloaded from CareLink will appear (without any IMPORTANT CSV files in it!)
NodejsPath='/c/Program Files/nodejs' # Where Nodejs installed on your system
MousePath='/c/Users/matt/Nightscout' #Where MiniMouseMacro is installed
# ****************************************************************************************
# USER SPECIFIC Variables - Please enter your values here
# ****************************************************************************************
api_secret_hash='2ce212ef676099da17ec5aff64db0c83bf3f7b4f' # This is the SHA-1 Hash of your API-SECRET string - eg "ASANEXAMPLE1" is transformed into...
your_nightscout='https://yourwebsite.azurewebsites.net' #'https://something.azurewebsites.net'
gap_mins=10 # time between CSV uploads (roughly). Suggest betweem 5 and 10 minutes and always start higher
Be sure to save the file afterwards ;-)
Start Firefox and manually login and go to the Upload page.
Manually start Mini Mouse Macro.
Record a simple macro to record you clicking the Finish button on that page.
Save the macro as mmcsv640g(.mmmacro) in the same directory as the application (e.g. /c/users/matt/nightscout)
(there's an example macro in the repo, which performs two clicks, covering the location of the button on the two different windows systems I've tested this on)
Automate
Aim: Pump - CareLink - CSV - Nightscout without having to do anything
Aim: Pump - CareLink - CSV - Nightscout without having to do anything
Start Firefox and maximise the window
Log into CareLink manually and check you can upload pump data and download a CSV file.
Always log in manually once a day to check all is well in CareLink Land.
Click on the Selenium IDE icon.
File, Recent Test Suites, click on yours...
Ensure Periodic running is 'on' (look for the highlighted clock symbol)
Open a Bash Shell (either Git Shell Git Bash as earlier) window and type:
cd "/users/matt/GitHub"
./mmcsv640g.sh "/c/users/matt/nightscout"
where /c/users/matt/nightscout is the directory you popped the updated config.sh file into.
Known Issues
Aim: Highlight that this is still work in progress...
V0.75 4th March 2016
- Dropping the odd data point between uploads - overhaul data selection to use timestamp and not line number...
- Bolus Entries can drop from display (but are still counted in IOB). Dig through where that comes from...
- Double vision-currently clears out CSV files to prevent IO error on pause to look for CSV files - an easy fix when I'm more awake...
- If you get stuck / accidentally upload a huge CSV file, delete Treatments (and possibly Entries) documents in your MongoDB to revive Nightscout...
- Removed Medtronic Predicted SG from default upload - stability issues that need more time to look at.
- Tweaks between different versions of Windows and GitHub... - using Git's "Git Bash" terminal might be safer
- If Firefox disables Selenium add-on: follow instructions here to set xpinstall.signatures.required preference to false (Please take note of all the warnings Firefox issues around doing this!)
- Square / Dual Bolus Insulin is marked at the end of the bolus period ie IOB will be under-estimated during a dual / square bolus and over-estimated at the end of the the bolus onward. This needs to be properly implemented.
- Every time you upload to CareLink your CareLink DB and CSV file becomes bloated by ~180 lines of summary information: that quickly mounts up. The long term impact of that on your CareLink dataset is unknown.
Update: If you've landed here looking for Nightscout on your 600-series pump, thanks for stopping by :) The simplest way to get your pump on to Nightscout is to use the 600-series Android Uploader. Enjoy!
Matt. AMAZING!! Thank you so much for the update and for spending the time to write up in detail how you have gone about setting up the work around for the 640g link to NS. I know work and family life is busy, especially when you have T1 children making time a precious commodity. From your instructions and comments against the codes, I can now see how this works with the CareLink login process, excel report generation and the scripts for upload to NS. It’s a shame that we need firefox, the selenium extension and the mouse macro. Otherwise I'm sure you would have found a windows phone with coding/apps capable of getting the job done and make this a truly mobile solution. I am going to order another Contour Next Link 2.4 dongle and give this a bash (our back up dongle is used by the school and it stays there). I will see how far I get in replicating your work. This is one step in the right direction. This will help my daughter sleep at night, as with this, I dont have to keep turning her over to get to the pump for readings or keep asking for pump readings every hour.
ReplyDeleteMany thanks! Good luck with your setup and taking that step towards freeing your daughter's data :-) Matt
DeleteHi Matt, hope all is well with Janki.
DeleteI've set up all the accounts (Mogo, Azure, GitHub linked fork to NS CGM). So as soon as the new Contour Next Link arrives, I will be installing the little softwares to get 640g, Carelink and Nightscout working in sync. I am planning on using a small windows laptop. I have one question, how is the 640g connecting with the contour next link dongle for the periodic call to upload and download the CSV? what is the work around for not having the units in very close proximity for the Carelink download to work.
Many thanks Matt. Im trying not to bug you with too many questions, using your blog and nighscount as my primary information source.
Hi there, sorry for the delay getting back to you. So the version currently up on the blog does rely on the Bayer plugged into a windows machine that's quite close to the pump (we find a couple of metres is the max range for us), so it works well at home at night and if play is limited largely to one room, but it's not perfect.
DeleteI do now have a solution that doesn't need the Windows machine in the vicinity, but will post that in a few days hopefully once I get the chance to pull the details together in a single post.
Matt, this is awesome. We just started on 640g on Monday and miss our Dexcom & Nightscout already a lot. Will need to get this up and running asap. We are a Apple household… any idea if I could repurpose my original Microsoft Surface to be the PC in the setup?
ReplyDeleteHi Jami, thanks! Not sure if the java plug in for carelink will work on your ARM-powered Surface. Easiest thing to try is to download Firefox, plug in the Bayer meter and give it a spin manually to see if it can... In theory, you could run this on a mac os device too (not the latest os I think?). Would need to tweak the call to the mouse clicker, but otherwise should work. Please let me know if you give either a go!
DeleteMatt
ReplyDeleteMany thanks for all your work on this and I know you are busy, so if you haven't the time to respond, don't worry.
I have followed your instructions but have ended up with the following error message:
Waiting for CareLink upload page...
./mmcsv640g.sh: line 66: 10#57 %: syntax error: operand expected (error token is "%")
Any ideas?
Thanks
Chris
Hi Chris, Sorry for the delay. If you hop over to https://www.facebook.com/littlet1d/ and message me there, I can try to take a look tomorrow. If you can copy and paste your config.sh file into the message that'd be great.
DeleteMy best guess from the info above is that you maybe have a space in the gap_mins line at the end of config.sh? It needs to read gap_mins=10 without any spaces
I'll try to get you to your direct message on FB tomorrow.
Thanks
matt
I m total lost with setting this up
ReplyDeleteSorry to hear that Unknown. You might find this post (http://littlet1d.blogspot.co.uk/2016/01/nightscout-on-640g-step-by-step-into.html) slightly easier to follow. I'm afraid it is early days and there are lots of steps, including a number of hoops you need to go through for a standard Nightscout installation. Please feel free to message me directly via www.facebook.com/littlet1d if you have any specific issues or questions for your setup. Wishing you luck - kind regards, Matt
Deletegot lost trying to set ths up
ReplyDeleteSorry to hear that Anthony. You might find this post (http://littlet1d.blogspot.co.uk/2016/01/nightscout-on-640g-step-by-step-into.html) slightly easier to follow. I'm afraid it is early days and there are lots of steps, including a number of hoops you need to go through for a standard Nightscout installation. Please feel free to message me directly via www.facebook.com/littlet1d if you have any specific issues or questions for your setup. Wishing you luck - kind regards, Matt
Delete