Skip to content

Instantly share code, notes, and snippets.

@khskekec
Last active February 4, 2026 08:30
Show Gist options
  • Select an option

  • Save khskekec/6c13ba01b10d3018d816706a32ae8ab2 to your computer and use it in GitHub Desktop.

Select an option

Save khskekec/6c13ba01b10d3018d816706a32ae8ab2 to your computer and use it in GitHub Desktop.
HTTP dump of Libre Link Up used in combination with FreeStyle Libre 3
@gjkoolen
Copy link

gjkoolen commented Feb 2, 2026

Hello everyone. I wrote a Python script that reads out my glucose level every 5 minutes, to send me a Telegram message when my sugar is not following a (very simple) model. So it warns me when I have to use insulin. I use this for more than a year and it helped me reduce my HbA1C significantly. The script runs on a Raspberry Pi Zero. The only drawback is that every time I eat (and thus use insulin), I send a Telegram message to the bot. This information is needed for the model.
This glucose checker is very useful when for instance the whole night my level is high, but just under the alarm level. I will be awakened by the (annoying) Telegram message receive sound. Or when glucose level starts rising again 2 hours after a meal. Also then I am alerted and can compensate with insulin, to remain well under the alarm level.
The code consists of 2 services: the glucose checker service and Telegram bot service. Connected by an MQTT broker.
It is on my wish list to train an ML model, based on glucose data from the past.
If anyone is interested in the code, or in having more information, please let me know.

@Mynuggets-dev
Copy link

Mynuggets-dev commented Feb 2, 2026 via email

@Mynuggets-dev
Copy link

Mynuggets-dev commented Feb 2, 2026 via email

@gjkoolen
Copy link

gjkoolen commented Feb 2, 2026

@Mynuggets-dev Good questions. My Python script only stores data of the last 30 minutes, and uses that to determine if all is well. No DB needed. The Telegram bot is only to bridge between my house MQTT and external Telegram. The bot only relays between my phone and the Python script (via Telegram and MQTT). I got diabetes when I was 43 (in 2009).
Before each meal I administer insulin, and then usually it goes up and then down to normal level after 3 hrs. However, sometimes at t=2 hrs the Python script notices that the level goes not down anymore, but up again (depending on meal). In such cases I get a message, I compensate, and the final curve looks very good. My doctor asked me how I got my levels so flat, and I told him I use control techniques (is also my job) and this Python script.
Same at nighttime: usually very good, but sometimes I miscalculate, and then it's good to receive a message so I can compensate.
Freestyle Libre has a "bug" in my opinion: if my level is above alarm level before I go to sleep, I compensate (of course), but if I don't compensate enough, it can remain the whole night above the alarm level without raising any alarm. Abbott should automatically repeat any alarm after 3 hours in my opinion. Also for such cases this Python script is good.
Hope this explains :-)

@Mynuggets-dev
Copy link

@Mynuggets-dev Good questions. My Python script only stores data of the last 30 minutes, and uses that to determine if all is well. No DB needed. The Telegram bot is only to bridge between my house MQTT and external Telegram. The bot only relays between my phone and the Python script (via Telegram and MQTT). I got diabetes when I was 43 (in 2009). Before each meal I administer insulin, and then usually it goes up and then down to normal level after 3 hrs. However, sometimes at t=2 hrs the Python script notices that the level goes not down anymore, but up again (depending on meal). In such cases I get a message, I compensate, and the final curve looks very good. My doctor asked me how I got my levels so flat, and I told him I use control techniques (is also my job) and this Python script. Same at nighttime: usually very good, but sometimes I miscalculate, and then it's good to receive a message so I can compensate. Freestyle Libre has a "bug" in my opinion: if my level is above alarm level before I go to sleep, I compensate (of course), but if I don't compensate enough, it can remain the whole night above the alarm level without raising any alarm. Abbott should automatically repeat any alarm after 3 hours in my opinion. Also for such cases this Python script is good. Hope this explains :-)

yeah in the librelinkup i found they do like data sanitizing and its compressing high / low readings ( 20mins time for insulin for the fat cells etc so 30min could be half the issues for a good source of data ) that's why i just log the readings raw data and compile it myself, all my analytics are python functions i created based on Australian standards etc ( i like the pretty look but advice not to use as a direct refence, and i have handling incase trying to view more data than i have etc eg
image
and i have discord accounts that can link to a bot etc
image
and working on widgets too, i get alot of ideas from posts like these and issues, so thanks to anyone that posts for help or ideas 💕

@Mynuggets-dev
Copy link

ive been trying to add something to auto log mealtimes based on levels, but thats hard cause if you do it right it shouldnt detect the rapid changes 🤔

@Mynuggets-dev
Copy link

feel free to try it, only thing i ask is please don't use it like a source of truth, it can be flawed with my ' skill level ' https://diabetes.mynuggets.dev/

@gjkoolen
Copy link

gjkoolen commented Feb 4, 2026

@Mynuggets-dev Great that you exposed your scripting with others with your website! It looks good. Nice example for other developers. I hope one day I will provide machine-learned alerting service to others. At the moment I am too busy with other things. Keep going!

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