{"id":21909140,"url":"https://github.com/vensim/embedded_ml","last_synced_at":"2025-04-16T01:54:45.978Z","repository":{"id":36994926,"uuid":"353422120","full_name":"Vensim/Embedded_ML","owner":"Vensim","description":"Application of TinyML on an ESP32 system. To sample ECG data, feature gather and output new ML model based on sampled data to be re-compiled into ESP32. ","archived":false,"fork":false,"pushed_at":"2024-06-21T18:26:34.000Z","size":945,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-16T01:54:31.733Z","etag":null,"topics":["data-processing","ecg","esp32","esp32-arduino","machine-learning","sampling","tinyml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vensim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-31T16:30:44.000Z","updated_at":"2025-03-24T16:59:18.000Z","dependencies_parsed_at":"2022-08-19T00:10:47.362Z","dependency_job_id":null,"html_url":"https://github.com/Vensim/Embedded_ML","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vensim%2FEmbedded_ML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vensim%2FEmbedded_ML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vensim%2FEmbedded_ML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vensim%2FEmbedded_ML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vensim","download_url":"https://codeload.github.com/Vensim/Embedded_ML/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249183107,"owners_count":21226141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-processing","ecg","esp32","esp32-arduino","machine-learning","sampling","tinyml"],"created_at":"2024-11-28T17:15:26.600Z","updated_at":"2025-04-16T01:54:45.954Z","avatar_url":"https://github.com/Vensim.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Embedded ML for ECG applications\n[![pipeline status](https://gitlab.com/Sesven/Embedded_ML/badges/main/pipeline.svg)](https://gitlab.com/Sesven/Embedded_ML/-/commits/main)\n## Introduction\n\n\u003e Objective of this repository is to acquire experience in developing products and to get familiar with new technologies. Secondary objective is to create a framework of sensor to machine learning starting with raw electrocardiogram data with the intent of quantize how deviated the heart wave is from sample data and in addition to predict future heart states with different activities. In the future different sensors could be applied such as electromyography sensors.\n\nServer-runner added.\n\n\n![ECG Features](ECG_feature_extraction_current.png)\n\n![Fourier](Fourier_output.png)\n\n![ML Prediction](https://user-images.githubusercontent.com/39244927/113791372-60554e00-973b-11eb-96e5-5e616ea720b7.png)\n\n\n\n\u003cimg src=\"https://user-images.githubusercontent.com/39244927/113945275-edf97200-97fd-11eb-8a9f-ba0aee1ba3b5.png\" width=\"300\" height=\"400\"\u003e\n\n\n## Current progress\n\nGoal | Progress\n------------ | -------------\nECG to ESP data aquisition | Y\nESP UDP control | Y\nESP UDP data transmission | Y\nFeature extraction | Basic\nMachine Learning model | In progress\nESP Prediction | In progress\n\nAnalog input produces 50~ Hertz noise, research into implementing Low-pass filter\n\nImplement windowing to individual heart pulses for additional feature extraction\n\nFind way to change Machine Learning model, the hex array, without recompiling whole program. \n\n\n## Installation\n\nOptional: \nInitialise virtual python env.\n \n```bash\nconda create -n EmbeddedML_env python=3.8.5\nconda activate EmbeddedML_env\npip install requirements.txt\n```\n\n\nInitialise system variables with bash script. This will give prompt for ESSID, Password and UDP IP configurations.\n```bash\nchmod +x env_init.sh\n./env_init.sh\n```\nOr edit the script files and the ESP32.ino file manually.\n\nWill output network interface configuration. Use the ip the python scripts will be run off.\n\n\nInstall the ESP32 arduino program with new initialised values. \n\n\nPlace ECG electrodes.\n\nImage from ConnectMed.com\n\u003cimg src=\"https://user-images.githubusercontent.com/39244927/113597321-71b33300-9633-11eb-9fbe-8872a5d8d0fa.png\" width=\"500\" height=\"500\"\u003e\n\n\nTest the output of the ECG sensor in a serial monitor.\n```bash\npython UDP_init_test_mode.py\n```\n\nGather sample data. Enable sampling server then initialise sampling.\n```bash\npython ECG_sampling_server.py\npython UDP_init_sample_mode.py\n```\nExample output\n\n![img](ECG_sample_good.png)\n\n\n\nWith sampled data, perform feature extraction\n```bash\npython ECG_feature_extraction.py\npython Visualise_ECG_features.py # Optional, to visualise the output.\n```\n\nFeature extraction example output.\n\n![img](ECG_feature_extraction_current.png)\n\n\n\nTo generate model with featured data \n```bash\npython ECG_ML_Modelgen.py\n```\nThis script will produce 2 files, ECG_model_quantized.tflite  and  ECG_ML_Model.h.\n\nECG_ML_Model.h to be used with Arduino IDE as header file.\n\nRecompile the ESP32 with the new header file and activate Machine Learning mode\n```bash\npython UDP_init_ML_mode.py\n```\nExpected output\n![image](https://user-images.githubusercontent.com/39244927/113791372-60554e00-973b-11eb-96e5-5e616ea720b7.png)\n\n\n\nHeart sensor schematic.\n\n![image](Datasheets/Schematic_Heartmonitor.png)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvensim%2Fembedded_ml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvensim%2Fembedded_ml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvensim%2Fembedded_ml/lists"}