{"id":27102182,"url":"https://github.com/jpcodes44/heartclick5_lib","last_synced_at":"2025-08-20T19:04:24.988Z","repository":{"id":286025394,"uuid":"960107969","full_name":"JPCodes44/HeartClick5_lib","owner":"JPCodes44","description":"Arduino Library for the HeartClick5 Spo2 sensor","archived":false,"fork":false,"pushed_at":"2025-04-03T22:17:43.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T21:14:20.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/JPCodes44.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-03T21:49:01.000Z","updated_at":"2025-04-03T22:18:32.000Z","dependencies_parsed_at":"2025-04-03T23:23:33.299Z","dependency_job_id":null,"html_url":"https://github.com/JPCodes44/HeartClick5_lib","commit_stats":null,"previous_names":["jpcodes44/heartclick5_lib"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JPCodes44/HeartClick5_lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCodes44%2FHeartClick5_lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCodes44%2FHeartClick5_lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCodes44%2FHeartClick5_lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCodes44%2FHeartClick5_lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JPCodes44","download_url":"https://codeload.github.com/JPCodes44/HeartClick5_lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCodes44%2FHeartClick5_lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271369520,"owners_count":24747795,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-04-06T15:35:15.081Z","updated_at":"2025-08-20T19:04:24.906Z","avatar_url":"https://github.com/JPCodes44.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# HeartClick5 Arduino Driver\n\nThis Arduino library enables communication with the **HeartClick5** sensor module, based on the **AFE4404 analog front-end** by Texas Instruments. It supports I2C communication and allows you to access raw LED and ambient photodiode data for heart rate and SpO₂ signal extraction.\n\n---\n\n## 📦 Files\n\n- `HeartClick5.h` — Class interface definitions\n- `HeartClick5.cpp` — Implementation of register access and signal readout\n- `HeartClick5_hal.cpp` — Optional hardware abstraction helpers (if required)\n\n---\n\n## 🔌 Hardware Interface\n\n- **I2C Address**: `0x58`\n- **Power**: 3.3V (recommended)\n- **Pins**:\n  - `SCL` → Arduino SCL\n  - `SDA` → Arduino SDA\n  - `GND` → Ground\n  - `VCC` → 3.3V\n  - Optional `RST` → Digital pin (if using software reset)\n\n---\n\n## 🚀 Getting Started\n\n### 1. Clone or Copy the Files\n\nPlace `HeartClick5.h`, `HeartClick5.cpp` in your Arduino project folder.\n\n### 2. Include and Initialize the Sensor\n\n```cpp\n#include \u003cWire.h\u003e\n#include \"HeartClick5.h\"\n\nHeartClick5 heartSensor(0x58); // Default I2C address\n\nvoid setup() {\n  Serial.begin(9600);\n  Wire.begin();\n\n  if (heartSensor.begin()) {\n    Serial.println(\"✅ HeartClick5 initialized.\");\n  } else {\n    Serial.println(\"❌ Sensor not found.\");\n    while (1); // Halt\n  }\n}\n```\n\n---\n\n## 🧠 Example: Reading SpO₂ Signal\n\nThe most relevant signal for oximetry is the **difference between LED2 and its ambient phase**, accessible via `getLed2MinusAled2Val()`.\n\n```cpp\nvoid loop() {\n  int32_t rawSpO2 = heartSensor.getLed2MinusAled2Val();\n  Serial.println(rawSpO2);\n  delay(100);\n}\n```\n\n---\n\n## 🛠 API Reference\n\n### Initialization\n\n```cpp\nHeartClick5 sensor(0x58);\nsensor.begin();\n```\n\n### Signal Readouts (24-bit Registers)\n\n```cpp\nint32_t getLed2Val();\nint32_t getAled2ValLed3Val();\nint32_t getLed1Val();\nint32_t getAled1Val();\nint32_t getLed2MinusAled2Val(); // Preferred for SpO₂\nint32_t getLed1MinusAled1Val(); // Preferred for HR\n```\n\n---\n\n## 📊 SpO₂ Estimation Logic\n\nTo compute SpO₂:\n\n1. Sample both `LED2 - ALED2` and `LED1 - ALED1` over time.\n2. Calculate the AC and DC components.\n3. Use the ratio-of-ratios method:\n\n```math\nR = (AC_red / DC_red) / (AC_ir / DC_ir)\nSpO₂ ≈ 110 - 25 × R\n```\n\nA moving average or peak-to-peak calculation is typically used for AC, and a long-term average for DC.\n\n---\n\n## 📘 Datasheet \u0026 References\n\n- 📄 [AFE4404 Datasheet (TI / MikroE)](https://download.mikroe.com/documents/datasheets/afe4404.pdf)\n- 🧪 [Texas Instruments AFE4404 Product Page](https://www.ti.com/product/AFE4404)\n- 📚 MikroElektronika Heart Rate 5 Click board\n\n---\n\n## 🧪 Advanced Usage\n\nYou can also access and configure register-level controls:\n\n- Pulse timing\n- LED current settings\n- Gain settings\n- TIA bandwidth\n- Power modes\n\nUse setters like `writeRegister(uint8_t reg, uint32_t val)` or expose additional API calls.\n\n---\n\n## 🧑‍💻 Author\n\nAdapted by your team from MikroE’s C library to Arduino C++ for easy integration with embedded projects.\n\n---\n\n## 📝 License\n\nMIT License or based on MikroElektronika SDK license if using their base source.\n```\n\nLet me know if you want this converted to PDF, added to a repo, or expanded with visuals or usage diagrams!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpcodes44%2Fheartclick5_lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpcodes44%2Fheartclick5_lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpcodes44%2Fheartclick5_lib/lists"}