Skip to content

This Python code powers a non-invasive glucose monitor that analyzes breath acetone levels using an MQ-138 sensor connected to a Raspberry Pi. It applies machine learning (Random Forest) to estimate glucose levels and displays the results in real-time via a Tkinter GUI, updating every 2 seconds.

Notifications You must be signed in to change notification settings

SammyTourani/Glucose_Monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glucose Monitor

Overview

The Glucose Monitor is an advanced breath-based glucose monitoring system that utilizes a Raspberry Pi, sensors, machine learning, and a graphical user interface (GUI) to estimate glucose levels non-invasively. This project is ideal for demonstrating skills in hardware integration, machine learning, and software development.

The system predicts glucose levels based on acetone levels detected in breath using a Random Forest regression model. It features real-time monitoring, data logging, and visualization capabilities.


Features

  • Sensor Integration: Reads acetone levels using the MQ-138 sensor connected to a Raspberry Pi via MCP3008 ADC.
  • Machine Learning: Predicts glucose levels using a trained Random Forest regression model.
  • Interactive GUI: Displays real-time glucose level estimates with a Tkinter-based interface.
  • Data Logging: Logs sensor readings and predictions to a CSV file for later analysis.
  • Expandable Architecture: Modular codebase for easy extension and scalability.
  • Real-Time Updates: Continuously updates glucose level predictions every 2 seconds.

Project Structure

Glucose_Monitor/ ┣━ main.py # Main program entry point ┣━ gui.py # GUI-related code ┣━ sensor.py # Sensor reading logic ┣━ model.py # Machine learning model training and prediction ┣━ utils.py # Utility functions (data logging, alerts) ┣━ data/ ┃ ┗━ glucose_log.csv # Logs of glucose readings ┣━ requirements.txt # Python dependencies ┗━ README.md # Project documentation


Requirements

This project requires the following hardware and software:

Hardware:

  • Raspberry Pi (any model with GPIO support)
  • MQ-138 gas sensor (for acetone detection)
  • MCP3008 ADC (Analog-to-Digital Converter)
  • Jumper wires and breadboard

Software:

  • Python 3.7 or higher
  • Libraries (see requirements.txt)
    • numpy
    • pandas
    • scikit-learn
    • matplotlib
    • RPi.GPIO
    • tkinter

Installation

  1. Clone this repository:

git clone https://github.com/yourusername/Glucose_Monitor.git cd Glucose_Monitor

  1. Install the required Python libraries:

pip install -r requirements.txt

  1. Set up your Raspberry Pi hardware:
  • Connect the MQ-138 sensor to the MCP3008 ADC.
  • Wire the MCP3008 to your Raspberry Pi GPIO pins as specified in sensor.py.
  1. Run the program:

python main.py


Usage

Real-Time Monitoring:

  1. Launch the program by running main.py.
  2. The GUI will display real-time glucose level predictions based on acetone readings from the sensor.
  3. The system updates every 2 seconds.

Data Logging:

  • All sensor readings and predicted glucose levels are automatically saved to data/glucose_log.csv for future analysis.

Alerts:

  • You can extend the project to send alerts via email or SMS if glucose levels exceed safe thresholds (see utils.py for customization).

How It Works

  1. Sensor Reading:
  • The MQ-138 sensor measures acetone levels in breath.
  • The Raspberry Pi reads these values via MCP3008 ADC.
  1. Machine Learning Model:
  • A Random Forest regression model predicts glucose levels based on acetone values.
  • The model is trained on simulated data but can be updated with real-world data.
  1. GUI:
  • A Tkinter-based GUI displays real-time glucose estimates.
  • Users can monitor their predicted glucose levels interactively.
  1. Data Logging:
  • Sensor readings and predictions are logged into a CSV file for analysis and visualization.

Future Enhancements

Here are some potential ways to expand this project:

  1. Cloud Integration:
  • Send data to a cloud platform (e.g., AWS IoT or Firebase) for remote monitoring.
  1. Mobile App:
  • Create an Android/iOS app to display real-time glucose data.
  1. Improved Machine Learning:
  • Use more advanced models like Gradient Boosting or Neural Networks.
  1. Real Data Integration:
  • Train the model with real-world breath-based glucose datasets.
  1. Alerts & Notifications:
  • Integrate Twilio or an email API to send notifications when glucose levels are abnormal.

License

This project is open-source under the MIT License.


Acknowledgments

Special thanks to open-source contributors and developers who maintain libraries like Scikit-learn, Matplotlib, and RPi.GPIO, which made this project possible.

About

This Python code powers a non-invasive glucose monitor that analyzes breath acetone levels using an MQ-138 sensor connected to a Raspberry Pi. It applies machine learning (Random Forest) to estimate glucose levels and displays the results in real-time via a Tkinter GUI, updating every 2 seconds.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages