Bluetooth help

I have a medical device (Dexcom) that sends my glucose level by BLE to my phone every ten minutes. My phone then sends that data to a server in the cloud. Another app on my phone can download that data from the cloud, as well as can my doctor. There are a few programs that can also get the data, including the Dexcom component in Home Assistant. From Home Assistant, I publish the data over MQTT to a few displays in my house, giving me a view of the latest reading.

What I would like to do is just intercept the data from the device.

When I put this line by itself,
esp32_ble_tracker:
I see a lot of unknown BLE devices- I didn’t think I had so many in the house.

But the one I am interested in showed a name:

[20:03:13][D][esp32_ble_tracker:720]: Found device E9:5C:F3:80:0B:0F RSSI=-87
[20:03:13][D][esp32_ble_tracker:741]:   Address Type: RANDOM
[20:03:13][D][esp32_ble_tracker:743]:   Name: 'Dexcom0S'

Next, I tried this:

esp32_ble_tracker:

binary_sensor:
  - platform: ble_presence
    mac_address: E9:5C:F3:80:0B:0F
    name: "Dexcom"

sensor:
  - platform: ble_rssi
    mac_address: E9:5C:F3:80:0B:0F
    name: "Dexcom RSSI value"

And this is the result:

[22:03:13][D][binary_sensor:036]: 'Dexcom': Sending state ON
[22:03:13][D][sensor:125]: 'Dexcom RSSI value': Sending state -99.00000 dB with 0 decimals of accuracy

How can I discover what else the device can tell me?

I would first have a look with the nRF Connect for Mobile app to see what BLE services the device offers.

Have a look at

You might get further insight…

This would be great, but I have a feeling dexcom uses encryption.

However I agree it would be good to intercept this, but it won’t work unless you carry the esp with you.

Thanks, but no additional data.

Thanks for the link. I had searched for a BLE scanner on my phone and found nothing useful. This one gives me more info, specifically the UUIDs of the services.

I added this code:

sensor:
  - platform: template
    name: "BLE Sensor"
    id: ble_sensor

esp32_ble_tracker:
  on_ble_service_data_advertise:
    - mac_address: E9:5C:F3:80:0B:0F
      service_uuid: "1800"
      then:
        - lambda: 'id(ble_sensor).publish_state(x[0]);'
And the results in the log:		
[17:58:13][D][ble_client:047]: Found device at MAC address [E9:5C:F3:80:0B:0F]
[17:58:13][I][ble_client:085]: Attempting BLE connection to e9:5c:f3:80:0b:0f
[17:58:15][I][ble_client:161]: Service UUID: 0x1800
[17:58:15][I][ble_client:162]:   start_handle: 0x1  end_handle: 0x9
[17:58:15][I][ble_client:341]:  characteristic 0x2A00, handle 0x3, properties 0x2
[17:58:15][I][ble_client:341]:  characteristic 0x2A01, handle 0x5, properties 0x2
[17:58:15][I][ble_client:341]:  characteristic 0x2A04, handle 0x7, properties 0x2
[17:58:15][I][ble_client:341]:  characteristic 0x2AA6, handle 0x9, properties 0x2
[17:58:15][I][ble_client:161]: Service UUID: 0x1801
[17:58:15][I][ble_client:162]:   start_handle: 0xa  end_handle: 0xd
[17:58:15][I][ble_client:341]:  characteristic 0x2A05, handle 0xc, properties 0x20
[17:58:15][I][ble_client:341]:  characteristic 0x2A29, handle 0x10, properties 0x2
[17:58:15][I][ble_client:341]:  characteristic 0x2A24, handle 0x12, properties 0x2
[17:58:15][I][ble_client:341]:  characteristic 0x2A26, handle 0x14, properties 0x2
[17:58:15][I][ble_client:161]: Service UUID: F8083532-849E-531C-C594-30F1F86A4EA5
[17:58:15][I][ble_client:162]:   start_handle: 0x15  end_handle: 0xffff
[17:58:15][I][ble_client:341]:  characteristic F8083533-849E-531C-C594-30F1F86A4EA5, handle 0x17, properties 0x12
[17:58:15][I][ble_client:341]:  characteristic F8083538-849E-531C-C594-30F1F86A4EA5, handle 0x1a, properties 0x12
[17:58:15][I][ble_client:341]:  characteristic F8083534-849E-531C-C594-30F1F86A4EA5, handle 0x1d, properties 0x28

Where do I go next?

It’s all in the esphome doc.
The 0x180x services are standard ones. Looks for the GATT specification.

The UUiD one is probably proprietary.

I’m not sure about the encryption. Probably not on the download since the Dexcom component doesn’t ask for any decryption key.

I already have a few displays around the house that receive data from the Home Assistant component published over MQTT.


(One of these days I will get around to designing a case for them).

The idea is that I would replace the Wemos D1 on each display with an ESP32. If I am in the room with one of these displays, then it will publish the data to the other displays on my network. But when I travel, it would be a nice display in my hotel room, or on the dashboard of my car to give me an idea of where I am and where I am going (glucose-wise). I am too lazy to look at my watch with the Dexcom face. (Actually, I can’t count on the watch app to work reliably enough).

I use nightscout to store my data and xDrip+ to get it onto my phone from the dexcom.

HA has a nightscout integration and once it is in HA it can go to the displays in my house, or a notification to kodi or my smart tv or an esphome screen or a openhasp screen or whereever.

I suspect the bluetooth stuff will be found in the Health Care Profiles of BLE - see Bluetooth Low Energy - Wikipedia and Bluetooth.com has a lot of docs on bluetooth programming.

I believe that there is a limit to how many devices you can pair to a dexcom transmitter - I pair my phone and my pump. I think the limit may be two or three, so the idea of a number of esp32’s to pair to round the house might not work.

Cheers, hope you are keeping well, it’s a tough disease. It’ll be 50 years for me in a couple of years.

Take a look at this, search for CGM as it is a different profile to Glucose

https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=524815

Also googling that first long uuid comes up with this

And the 16 bit UUIDs are found here https://btprodspecificationrefs.blob.core.windows.net/assigned-values/16-bit%20UUID%20Numbers%20Document.pdf

I hadn’t thought of that. I have two devices currently linked to the transmitter, my phone and the original Dexcom receiver. I am wondering if the four-character transmitter code is a PIN code? If so, the HA BLE tools won’t work anyway. I think it’s time to shelve this idea.

I have been unable to get Nightscout to work after they switched database providers about a year ago. Its the most incredibly convoluted Rube Goldberg integration that I’ve ever encountered. Sugarmate used to have an API where I could get my current BG (in JSON) from a simple web interface. They took that offline claiming that Dexcom made them do it.

I thought that xDrip was a pump?

xDrip is a data gatherer for android. It will also link to WearOS which may fix your watch problem.

Yeah nightscout is a bit tricky to set up, but works fine once you get it running. It’s not that hard, really a matter of finding the right online howto.

My problem with Nightscout is that I had a previous configuration with Nightscount. When they changed database providers a year ago, I wasn’t able to get the new database working, so I simply gave up since I had Home Assistant component and Sugarmate API which were both much easier to set up.
When Sugarmate stopped providing the API, I tried to set up Nightscout again, but I couldn’t because my email address already had an account, and it was in some kind of limbo. I may try again using a gmail address.

There was a nightscout upgrade howto.

The dexcom G6 transmitter has only two BT “slots”: 1=(Dexcom_receiver, pump, or something else) 2=(mobile / phone). So in order to bond/authenticate to the transmitter for a BT reading, you need an available slot. Your case sounds like you are already using both slots, so probably not going to get far without changes.

If you were willing to give up the receiver, you could use some code in an ESP32 such as: https://github.com/TheEpicBigBoss/Dexcom-ESP32-Reader in ESPHome which can relay the data to your HA. But, the much easier route is to just setup Nightscout and use the HA-integration: Nightscout - Home Assistant

I have considered hacking together an ESP32 reader so I do not need to have my phone with me while at home, for example. But an Xdrip±WearOS watch acting as a collector from the transmitter is probably a better solution and is already coded, you just need an appropriate watch and phone.

Good luck!

Nice to see another sufferer here :slight_smile:

1 Like

Sorry to revive this old topic, but I also have a G7 and was wondering how possible this is or if anyone has an update. I feel like it should be possible (even if the data is encrypted). I use the Suggah app on iOS (Which I think is basically Xdrip) to sync my readings to nights out, but it intermittently loses connection even though I always have my phone on me. The G7 has a slot for a Phone, Watch and Receiver, but I still managed to add it to the Suggah app, It has to be a passive reading somehow that doesn’t require a Bluetooth pairing of the device.