An open API service indexing awesome lists of open source software.

https://github.com/jpcodes44/heartclick5_lib

Arduino Library for the HeartClick5 Spo2 sensor
https://github.com/jpcodes44/heartclick5_lib

Last synced: 11 months ago
JSON representation

Arduino Library for the HeartClick5 Spo2 sensor

Awesome Lists containing this project

README

          

# HeartClick5 Arduino Driver

This 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.

---

## πŸ“¦ Files

- `HeartClick5.h` β€” Class interface definitions
- `HeartClick5.cpp` β€” Implementation of register access and signal readout
- `HeartClick5_hal.cpp` β€” Optional hardware abstraction helpers (if required)

---

## πŸ”Œ Hardware Interface

- **I2C Address**: `0x58`
- **Power**: 3.3V (recommended)
- **Pins**:
- `SCL` β†’ Arduino SCL
- `SDA` β†’ Arduino SDA
- `GND` β†’ Ground
- `VCC` β†’ 3.3V
- Optional `RST` β†’ Digital pin (if using software reset)

---

## πŸš€ Getting Started

### 1. Clone or Copy the Files

Place `HeartClick5.h`, `HeartClick5.cpp` in your Arduino project folder.

### 2. Include and Initialize the Sensor

```cpp
#include
#include "HeartClick5.h"

HeartClick5 heartSensor(0x58); // Default I2C address

void setup() {
Serial.begin(9600);
Wire.begin();

if (heartSensor.begin()) {
Serial.println("βœ… HeartClick5 initialized.");
} else {
Serial.println("❌ Sensor not found.");
while (1); // Halt
}
}
```

---

## 🧠 Example: Reading SpOβ‚‚ Signal

The most relevant signal for oximetry is the **difference between LED2 and its ambient phase**, accessible via `getLed2MinusAled2Val()`.

```cpp
void loop() {
int32_t rawSpO2 = heartSensor.getLed2MinusAled2Val();
Serial.println(rawSpO2);
delay(100);
}
```

---

## πŸ›  API Reference

### Initialization

```cpp
HeartClick5 sensor(0x58);
sensor.begin();
```

### Signal Readouts (24-bit Registers)

```cpp
int32_t getLed2Val();
int32_t getAled2ValLed3Val();
int32_t getLed1Val();
int32_t getAled1Val();
int32_t getLed2MinusAled2Val(); // Preferred for SpOβ‚‚
int32_t getLed1MinusAled1Val(); // Preferred for HR
```

---

## πŸ“Š SpOβ‚‚ Estimation Logic

To compute SpOβ‚‚:

1. Sample both `LED2 - ALED2` and `LED1 - ALED1` over time.
2. Calculate the AC and DC components.
3. Use the ratio-of-ratios method:

```math
R = (AC_red / DC_red) / (AC_ir / DC_ir)
SpOβ‚‚ β‰ˆ 110 - 25 Γ— R
```

A moving average or peak-to-peak calculation is typically used for AC, and a long-term average for DC.

---

## πŸ“˜ Datasheet & References

- πŸ“„ [AFE4404 Datasheet (TI / MikroE)](https://download.mikroe.com/documents/datasheets/afe4404.pdf)
- πŸ§ͺ [Texas Instruments AFE4404 Product Page](https://www.ti.com/product/AFE4404)
- πŸ“š MikroElektronika Heart Rate 5 Click board

---

## πŸ§ͺ Advanced Usage

You can also access and configure register-level controls:

- Pulse timing
- LED current settings
- Gain settings
- TIA bandwidth
- Power modes

Use setters like `writeRegister(uint8_t reg, uint32_t val)` or expose additional API calls.

---

## πŸ§‘β€πŸ’» Author

Adapted by your team from MikroE’s C library to Arduino C++ for easy integration with embedded projects.

---

## πŸ“ License

MIT License or based on MikroElektronika SDK license if using their base source.
```

Let me know if you want this converted to PDF, added to a repo, or expanded with visuals or usage diagrams!