Friday, December 6, 2013

Taskbar Widget

Since I already have the C# laying around, I created a program to show the BG in my Taskbar.  

Tuesday, November 12, 2013

Changing the Transmitter Battery ?

Well, I'm getting screwed by my insurance company, so I'm paying for the transmitter out of pocket.
Once I have my replacement in hand, we will be covering replacing the transmitter battery.
Stay tuned.

12/6: Update:  Battery is still working.  I think the low battery conniption the Dex throws must be coded in, and has nothing to do with the battery.  Very uncool.  Do the math, if the battery was so low 40 days ago, that the receiver was missing signals etc., for a week, how does it fix itself and work problem free after that?  Range is still great, not like some internal setting kicked the transmitter output down to conserve battery.

Friday, September 27, 2013

Software Improvements

I've had a while to field test this.  Lost one watch water skiing.  Some issues that have been bothering me:
  1. Since the RasPI doesn't have an internal clock, and the MetaWatch resets each time you re-charge it (ridiculous), I have to spend a few minutes with the RasPI networked to get the time correct.  Not ideal, this needs to be as close to "grab and go" as I can get it.
  2. Bluetooth issues.  This thing uses "bleeding edge" bluetooth.  I create a new bluetooth connection to the watch every time there's a new value to send.  Intermittently, I start getting "bluetooth.btcommon.BluetoothError: (113, 'No route to host')" errors.  Sometimes the device recovers, or I just reboot the PI and things go back to normal.  

The Time Issue:
Finally figured out how to get the current time from the Dex.  I do this on startup and set the RaspPI system time to the current time reported by the Dexcom.  This keeps everything in sync, and gives me a functional watch to boot.  One of many "interesting" issues here, C# on Debian doesn't do dates.  Huge bug.  Luckily, I can pass "Seconds since the epoch" to the Unix date function and it does it for me.

I've been using "/etc/init.d/bluetooth restart" after every call to the watch.  Randomly, the bluetooth device time's out, and stays unreachable.  Determined today that calling "hciconfig hci0 reset" fixes that issue.  So now I'm using hciconfig after every call instead of restart.

Thursday, July 11, 2013

Getting it Smaller

Took a shot at reducing the case size.  The large version(7"x5"x2")  is good for 7.5 hours, and is nearly indestructible.  The small case is a tiny fishing tackle box, the size of a match box(5"x3"x1.75"), good for 2.5 hours.  I've left a USB cord attached to it, so it can be plugged in whenever possible.  Decent for trips to the gym.

5" long is as small as you can get and fit the Dexcom with it plugged in.  Had to special order a 90 degree micro usb plug. 

A picture of the inside of the box.  The battery is underneath.  The switch allows me to charge the battery while still running the PI.  Not sure what's with this brand of battery/charger circuit(enercell), but it shuts off power when charging.  The PI has been extensively modified.  I've cut off just about everything that sticks up.  Also, relocated the USB ports.  Allot of time was spent with a magnifying glass doing this work.  I've also shortened the numerous USB cables.  You run out of room fast with extra cord length.  USB plugs were also shaved with a razor blade to make them lower profile, and more bendable.  Power is supplied to the PI via the GPIO pins, since I didn't have another 90 degree USB.  Also removed the case from the battery, which freed up 1/8", allowing the Dex to sit on a plastic plate, and not directly on the circuitry beneath.

Did some additional tests with the Chronos, battery life is shorter on the transmitter side then using bluetooth.  So the Chronos is entirely out of the picture now.  

Monday, July 1, 2013

A fully functional Dex Watch...

Finally got this running on a Raspberry PI, so it's portable.

This is a waterproof Otterbox.  Costs about the same as the Raspberry PI.  The PI is underneath the Dexcom.  Some modifications were made to the PI with a dremel!  I removed the audio out and all the pin headers, to allow the battery to sit flat in the case.  The Powergen battery gives about 7.5 hours.

I'm now using the Metawatch.  This is the only Waterproof smart watch on the market(at this time).

There's still mud on the watch from its first enduro.

I was also hoping for increased range, between the PI and the watch, but I'm not really getting that.  The range is maybe a few feet greater than the TI Chronos.  What I do get is an easier to use API for the watch, and the ability to make the watch buzz, for low and high alerts.  That's glucose on the left, the minute the reading was taken on the right.  Also, in the center I show up or down arrows for rapid rise/fall rates.  The minute indicator is so I know if things aren't working.

Initially I wrote everything in C#.  Then I ported it over to Linux on my laptop.  In Ubuntu Linux, I was unable to communicate with the Dexcom using the driver that Linux chose.  Luckily, when I tried this on the Raspberry PI, the driver that loaded there, worked fine.

Getting the Metawatch working was also a challenge.  I ended up using a python script ( that is publicly available.  The C# drawing routine that I was using to generate the bmp for the display wouldn't run on the PI, so I ended up making a call out to imagemagik.

This is it for now.  I'm still not thrilled with the overall size, but it works for me.  I think it could be feasible to use a jail broken iPhone 5, the major hurdle would be the USB driver.

Wednesday, June 5, 2013

Conquering the Dexcom API's and Shopping for Watches

I've made great progress with finding what to call in the Dexcom DLL's.  7 lines of code and I can get an XML document with everything on the receiver in it.  This works great from Windows.

Now the hard part.  I've figured out how to parse the raw serial data coming out of the Dex.  This should allow me to port this over to Linux without needing the Dexcom DLL's.   A rainy weekend is forecast, so I'll be trying to communicate with the Dex from the Raspberry PI.  I've already confirmed the PI will talk to the TI Watch without issue.

Now that I'm getting close, I'm getting greedy.  The TI Watch will work perfectly for my hazardous duty requirements, but it only has a transmit range of 10 feet or so.  The Dexcom will go to 20 feet.  I think I might have to look into the MetaWatch, water resistant and capable of greater distance with bluetooth.

I'm trying to avoid having to network with a Smart Phone though.  I don't want to have to pay for Hotspot features, nor do I want to be dependent on cell phone access.

Thursday, May 16, 2013

What's Next

This is giving me lots of ideas.  Big issue at the moment is the amount of horsepower I'm using to do this.  Can I reduce the foot print?  I originally wanted to do this with a micro controller, and that's still the ultimate goal.

Can I move all the software to a Raspberry Pi?  Only if I can get Dexcom Studio to run under Wine.  This would get things down to a manageable size, everything can live in a backpack or my gym bag.  Obviously, going out to dinner, I would just put the Dexcom in my pocket.

The Dexcom requires a windows driver and has proprietary code.  I should be able to "tell" the Dexcom to dump an XML file without using the studio.  Can I write a linux compatible driver, or again, use Wine.  This would definitely be capable of running on a Pi, then.  I have a working obsolete Dexcom 7 that is about to undergo some serious hacking.

And finally, the TI Chronos watch.  This is a product well on its way to obsolescence.  It only has a range of about 10 feet, which doesn't meet my gym requirement.  It's also fairly ugly.  Development looks like a nightmare, and not all features are accessible.  I have development environments configured in Linux for Open Chronos and Open Chronos NG.  I think neither of these supports the BlueRobin module though.
At a minimum, I'd like to get the glucose reading underneath the time, currently it occupies its own screen.

The MetaWatch looks like a better candidate.  This is TI's replacement for the Chronos.
Although, of all the Smart watches, the Sony looks best at the moment.  Glucose readings could be easily displayed on the Watch using a twitter feed.  Communicating with any of these watches looks like it would require a Smart Phone acting as a hotspot for the software that's reading from the Dex.  Then some mechanism to send the glucose reading as a text message, through the smart phone, to the watch.  

Looks like smart phone development is probably in my future...

Wednesday, May 15, 2013

Getting the glucose number from the Dexcom

It's hard to see in the photo, but the watch is showing the same value as the Dexcom.  

Now to get the current glucose reading from the Dex.  There's a software package, Dexcom Studio that comes with the Dex for downloading data from the gadget.  Interestingly, it's all written in C#.  Poking around in a $500 medical device's undocumented code, though, is something I'm not going to post...

Need another, "easier" way to get these numbers...  Playing around with the Dexcom studio software shows that it will download all of the watches data to an XML file, bingo!  A little C# code, and liberal use of the "sendkeys" command, and I can open and close the studio, and dump an XML file every few minutes.

Now, I can easily parse the file and get the Glucose value.  Using the process from my last posting, I can get the number onto my watch.  Success!

Sunday, May 12, 2013

Creating a Glucose Monitor Watch

One of the greatest improvements in Diabetes care in the last 20 years is the Continuous Glucose Monitor(CGM).  Dexcom makes arguably the best of these gadgets.  Currently, the monitor is an iPod Nano like gizmo that fits nicely in the pocket.  Still, it doesn't pass as a cellphone.  Additionally it's expensive.  There's no way around spending the money(or your insurance companies money), but destroying it by accident is best avoided.
All this technology, why can't I have my glucose reading in a watch.  One point that the industry appears blind to, is the people that have to use these things, would really like it if they could be better hidden.

So, how to get the numbers off of the Dexcom and send them to a "smart" watch ?  Additional bonus, the Dexcom can be safely stored somewhere near by and better protected from destruction when I'm on a dirt bike ride.  Also the form factor of the watch, allows me to keep track of the numbers when I'm kickboxing, since the monitor won't survive a hit.  Also, the smart watches are about half the price of a Dexcom unit, so they can be sacrificial.  The one I'm starting with is 1/10th the price.

Texas Instruments has an interesting product, the eZ340-Chronos, that's been out for a while.  I purchased one from Sparkfun.  The goal for the watch is to be able to send a number to it.  After a lot of time on Google, it became clear that the intent of the watch is to send limited information, not receive it.  The only receive mechanism that appears it would work, ie. display a glucose reading , real time, is the BlueRobin  heart rate monitor component.  The BlueRobin component isn't part of the watch that's really meant for developer customization.  A demo app for the Chronos, "Control Center", includes a sample program that sends "fake" heart rate values to the watch, exactly what I want.

I wasn't able to find source code for this product, and what code/documentation I could find for the BlueRobin  module, just confused me.  So, I loaded a Serial Port Monitor software package, and watched the packets being sent to the watch as I ran the demo.  What I found was:
Sending Hex "FF 02 03", starts BlueRobin .
Sending Hex "FF 05 04 XX" sends a number to the watch.  Where XX is the Hex representation of the integer I want to send.

Success, I can send a number to the watch, now to get the number!