LibreMonitor
##Monitor your Freestyle Libre.
LibreMonitor is a little DIY device that uses near field communication to read data from a Freestyle Libre sensor and transmit it via bluetooth low energy to an iPhone application. LibreMonitor scans the sensor every two minutes. It transfers all the 32 history values for the last eight hours and the 16 trend values for the current time and the last 15 minutes and displays them in a chart and in a table.
Be aware that only the so called raw data is used and you have to choose slope and intercept yourself to have the application calculate useful glucose values. Values that mostly work fine for my sensors are 0.13 for slope and -20 for offset. Any other internal information such as from the temperature sensors is not yet fully understood and thus neglected,
This code is published for the purpose that others can contribute and help to improve it or use it to improve their own devices.
LibreMonitor has no affiliation of any kind with Abbott. This is a DIY project for research purposes. The code provided here might provide wrong results. You will have to build your own device and are responsible for the results. Use at your own risk.
##What you need to build a LibreMonitor
####Hardware
Parts needed for a LibreMonitor are
- BM019 NFC module capable of ISO/IEC 15693 commands. Possible sources are Solutions Cubed LLC, Warbutech or Robotshop.
- Simblee or RFDuino and a corresponding USB Programming Shield. I recommend to get a startet kit. See their Webites for Distributors.
- Lipo, e.g. this one (100 mAh is fine for a full day).
- Lipo charger (optional), e.g. this or this from adafruit.
- Switch (optional but helpfull if you mount a lipo charger).
Wiring
Wire the parts as in the following diagram (courtesy to libxMike).
It is suggested to mount and test everything on a breadboard before soldering the final device. Below are pictures of another LibreMonitor device without lipo charger. As you can see, one can save a lot of space by cutting of the black part of the stacks for Pins GPIO2 to GPIO6, push them through the pin holes of the BM019 and then solder the parts together. Therefore you also have to cut of the stack pins on the other side, too. Furthermore, it is suggested to bend the black part of the other stacks by 90 degrees. Thus you can still plug in the USB Programming Shield (RFD22121) but save some space.
Another device, this time with a lipo charger:
####Software for the Simblee
The software to program the Simblee is standard Arduino code. It consists of LibreMonitor.ino and the library contained in LibreMonitorArduinoLibrary.zip. Refer to the Simblee quick start guide on the Simblee website on how to program the Simblee. If you wired your LibreMonitor as described above don't forget to reconfigure the SPI pins of the Simblee in the variant.h file (see the wiring information in LibreMonitor.ino for more information on this)
##iOS application
The iOS application requires Xcode 8, swift 3.0 and iOS 10. Download the Xcode project. Run cocopoads to install the charts library, needed for the blood sugar graph. Build the application and run it on the phone and start it. If you want to receive notifications for high or low glucose values and have a badge icon displayed, allow for the corresponding settings, when asked. Once the app is running set values for slope and offset (e.g. 0.13 and -20, press the corresponding row to get into the settings view). Connect to your Simblee by pressing "connect". Once the Simblee ist detected and connected the "Simblee status" should change to "Notifying" and be green. Place the LibreMonitor device above your Freestyle Libre and after no more than two minutes the data should be displayed or refreshed. See the scrrenshots below.
####Some explanations
The "Glucose" row shows the current glucose value and two "delta values" that show how the glucose is about to develop (linear extrapolation for the next fifteen minutes). The first delta value is the difference of the current and the oldest minute-value, the delta value in braces is the difference of the current glucose value and the glucose value from 8 minutes ago, multiplied by two. The two "prognosis" glucose values are calculated by adding the delta values to the current glucose value. Glucose is calculated from the raw value as follows:
glucose = raw * slope + offset
The "Last 15 minutes" and "Last eight hours" sections display the glucose values, corresponding date, the raw value, the 6 bytes of data as read from the Freestyle Libre sensor and some other test data.
####Trouble shooting
- If a crc is wrong, most likely the device is not located near enough to the Freestyle Libre sensor.
- If the data is not refreshed, disconnect and reconnect.
- If the device cannot be connected, check wether bluetooth is switched on.
##Suggested readings
Blog by Pierre Vandevenne with information on the internals of the Freestyle Libre and suggestions on how to choose slope and offset. Without his work all this would probably not have been possible.
##Similar projects
- LimiTTer. Similar device, but data is sent to xDrip+, an Android app.
- Freestyle Libre Alarm. Uses as Sony smart watch to read data from the Freestyle Libre and send it to an Android phone.
- Bluereader project by Sandra Kessler who got funding to build a small neat device. I intend to adapt this project to work with bluereader once the first devices are available.
- Android reader application by Viktor Bautista that was helpful at the beginning of this work.