How I Combined Nightscout and Ollama to Monitor My Son’s Glycemia with AI

As a parent of a child with diabetes, managing glycemia levels can feel like a full-time job...

· 5 min read
How I Combined Nightscout and Ollama to Monitor My Son’s Glycemia with AI

As a parent of a child with diabetes, managing glycemia levels can feel like a full-time job. Between tracking trends, analyzing data, and ensuring timely interventions, it’s a lot to handle. That’s why I turned to technology—specifically, the powerful combination of Nightscout and artificial intelligence with Ollama LLM Manager—to automate and enhance my son’s glycemia monitoring. Here’s how I did it.


What Is Nightscout?

For those unfamiliar, Nightscout is an open-source platform that lets you access and share continuous glucose monitor (CGM) data in real time. It’s a lifesaver for families like mine, as it provides a user-friendly way to keep track of glycemia trends. But while Nightscout is excellent at collecting and displaying data, it doesn’t offer in-depth analysis or actionable insights.

Welcome to Nightscout — Nightscout Documentation documentation

Why Ollama ?

That’s where Ollama came in. Ollama is a large language model (LLM) manager designed to run and integrate AI models for various tasks on-premises. By combining Nightscout’s real-time data with Ollama’s analytical capabilities, I found a way to generate automated reports and insights tailored to my son’s glycemia trends.

Ollama
Get up and running with large language models.

The Workflow: Nightscout Meets AI

  1. Data Collection with Nightscout: Nightscout continuously syncs data from my son’s CGM. This data includes blood glucose levels, trends, and alerts for high or low readings. Nightscout also provides an API, which was key to accessing this data programmatically.
  2. Integration with Ollama: Using Ollama, I deployed an AI model fine-tuned to analyze glycemia data. The model could identify patterns, such as:
    • Recurring highs or lows at specific times of the day.
    • Sudden spikes or dips that might correlate with meals, activities, or other factors.
    • Trends over time that required intervention or discussion with a healthcare provider.
  3. Automated Email Generation: I wrote a script that:
    • Pulled glycemia data from Nightscout’s API.
    • Get this data with Ollama for analysis.
    • Used the AI-generated insights to craft a personalized email summary.
    • Generate a graph of the last day and night to visualise the data
  4. Delivery: The final email includes:
    • A summary of key metrics (e.g., average glucose, time-in-range percentage).
    • Alerts for unusual patterns.
    • Recommendations for adjustments, such as changes in insulin dosage or meal timing.
ups and down of a day at school...

Privacy Matters: Why I Self-Host Everything

One of my biggest concerns when managing my son’s health data is privacy. That’s why I made the decision to self-host both Nightscout and Ollama. By keeping everything on servers I control, I ensure that sensitive data never leaves our private environment.

  • Nightscout: Hosted on a private server with strict access controls.
  • Ollama: Run locally on dedicated hardware, ensuring that AI processing happens securely without relying on third-party cloud services.

This setup not only provides peace of mind but also aligns with my commitment to safeguarding my son’s health information. In an era where data privacy is increasingly important, self-hosting is a step toward greater security and control.


The Technical Details

Here’s a simplified version of the tech stack:

  • Nightscout API: To retrieve real-time glucose data.
  • Ollama LLM Manager: To run the AI model that analyzes the data.
  • Python Script: Handles API calls, data parsing, and email formatting.
  • Email Service (e.g., SMTP): Automatically sends the analysis to my inbox.

For example, I used Python’s requests library to fetch data from Nightscout and smtplib to send the emails. Ollama’s integration was seamless, as it allows REST API calls to process text inputs and return AI-generated insights.


The Impact

This setup is a game-changer. Instead of spending hours manually reviewing data, I get a concise, AI-generated analysis in my inbox every day two time a day for two distinct periods: 6am / 8pm and 8pm / 6am. This has not only saved time but also improved my ability to spot trends and make timely decisions for my son’s care.

Some of the most valuable insights included:

  • Identifying that his glycemia often dropped during soccer practice, prompting us to adjust pre-practice snacks.
  • Noticing a pattern of morning highs, leading to adjustments in his basal insulin dose.
  • Catching unexpected post-dinner spikes, which we linked to hidden carbs in certain meals.

Lessons Learned

  1. Data Quality Matters: The better the data, the better the AI’s analysis. Ensure your Nightscout setup is accurate and consistent.
  2. AI Is a Tool, Not a Replacement: While Ollama provides valuable insights, it’s not a substitute for professional medical advice. Always consult your healthcare team before making major changes.
  3. Automation Reduces Stress: Automating repetitive tasks like data analysis and report generation frees up mental bandwidth for more important things—like spending quality time with my son.

What’s Next?

I’m now exploring ways to make the system even smarter. For instance:

  • Real-Time Alerts: Instead of daily emails, I’d like to implement instant notifications for critical events, like dangerously low glycemia levels.
  • Family Dashboard: A centralized web interface where we can view trends and insights at a glance, i already build a dashboard in grafana, need some more work.
  • Machine Learning Enhancements: Training a custom model on my son’s historical data for even more personalized recommendations. That's a lot of work, time and resource consuming.

Thoughts

Managing diabetes is a marathon, not a sprint. By combining the real-time data of Nightscout with the analytical power of Ollama, I’ve created a system that makes this journey a little easier. Technology can’t replace the human element of care, but it can certainly enhance it.

If you’re a parent navigating similar challenges, I highly recommend exploring tools like Nightscout and Ollama. With a bit of creativity and effort, you might just find a solution that works for your family too. If you need help, I'm here <3

Björn my son

Why we are not waiting ? Big Pharma and big health companies / laboratories are too slow to move because this auto immune sickness (among many others) brings them a lot of money (i mean A LOT). So we do what we can, as parents and we are not waiting for them to find a better solution to ease our kids lifes.