![A computer with the pulse.loop app running.](images/computer.png)
pulse.loop
An open source firmware for wearable pulse oximetry devices.
Goals
The goal of this project is the development of a wrist-worn pulse oximeter. Detection of vital signs from the wrist is a challenging task, as the signal is weak and the sensor is prone to motion artifacts, but this positioning is ideal for comfortable continuous monitoring.
Being a wearable device, it's important to have wireless access to recorded data. This is why we developed a companion app for iOS and macOS devices, along with two open source BLE modeling libraries.
![A render of an electronic bracelet.](images/loop_mobile.jpg)
Hardware
The project is based on the AFE4404 analog front-end, which is an ultra-small integrated circuit for optical bio-sensing applications, such as monitoring heart rate and SpO2. It can control up to three LEDs using variable drive and offset currents. The current detected by the photodiode is then amplified by a transimpedance amplifier and converted into a digital signal by a 22-bit ADC, which allows for high resolution measurements.
The AFE4404 is controlled by an ESP32-C3 microcontroller, which is a low-power, highly integrated Wi-Fi and Bluetooth LE SoC. It features a 32-bit RISC-V CPU with 4 MB of flash memory, allowing for development of complex applications. The ESP32-C3 is a great choice for this project because it's powerful enough to run advanced firmware among with the BLE stack, while retaining many power-efficient features. Being compatible with LLVM-based toolchains, the RISC-V core can be programmed in a variety of languages, including Rust.
Firmware
The firmware runs on top of the ESP-IDF framework, and plays a crucial role in ensuring accurate and reliable measurements. The automatic gain control adjusts the current of three LEDs to account for variations in reflected light intensity, keeping the signal within the dynamic range of the ADC. The wrist detection algorithm helps to filter out any meaningless readings, and the digital filters extract the DC and AC components of the signal, which are then used to calculate the SpO2 and heart rate values.
The Rust programming language was chosen for the development of the firmware, as it provides
many safety guarantees that are crucial for multi-threaded applications. Support for the
AFE4404 analog front-end is provided by a custom driver, based on the embedded-hal
traits. This way, the driver can be used on any microcontroller that implements it. The Bluedroid
Bluetooth LE stack was wrapped inside a safe Rust library, and it's making its way to become the
official implementation of BLE in esp-idf-hal
.
Software
The companion app developed for the project is developed in SwiftUI, a declarative UI framework, and it's available for iOS and macOS devices. The application connects to the pulse oximeter via Bluetooth Low Energy, enabling the real-time data monitoring and visualization. CharacteristicKit is a library which uses metaprogramming concepts to allow for an easy modelling of Bluetooth LE peripherals, and it's used as an high level abstraction layer over Core Bluetooth.
This software is not meant to be used by the end user, as it allows the set-up of many internal parameters. However, it can be used to test the device and to collect data for further analysis, and it's easily reducible to a simple monitoring app, while retaining to internally change the parameters, with no intervention from the user.
Results
In conclusion, the pulse oximeter was calibrated against a commercial device and the resulting data was processed with a MATLAB script. A regression model was obtained, which can be used to calculate the SpO2 from our device's measurements. The results show that the pulse oximeter is able to detect the heart rate and SpO2 with reasonable accuracy, considering the sensor location, which inherently presents certain limitations. Despite this, the project's outcome indicate the feasibility of utilizing a wrist-worn pulse oximeter for non-invasive monitoring.
However, there is still room for improvement. Future iterations could benefit from a calibration process conducted in a laboratory setting and further statistical analysis to enhance the accuracy and reliability of the measurements.