Sleep apnea sufferers are encouraged to sleep on their side and need to manage pulse oximetry and heart rate Many wearable devices are used, but the number of measurements while sleeping was low and unsatisfactory. I developed this monitor recorder to obtain detailed information. I hope this will be helpful to those interested in this subject.
Peripheral_1 consists of XIAO_BLE_Sense and a 3.7V 220mA(10 hours operation) battery, attached to the chest. Data from the built-in IMU is converted to Roll and Pitch with a Madgwick filter. Roll, Pitch, and battery voltage data are sent to Central every 240mS. To obtain stable sleeping posture data, it is important to attache Peripheral _1 closely to the chest.
Peripheral_2 consists of XIAO_BLE, a 3.7V 220mAh(10 hours operation) battery, and an I2C-connected MAX30102 breakout board, attached to the wrist and finger respectively. Two kind of pulse waveform data acquired every 30mS by the MAX30102 are used to calculate Heart rate and SpO2 values. Heart rate, SpO2, Pulse waveform, and battery voltage are sent to Central every 240mS. Pulse waveform data are sent together every 8 data. To obtain stable pulse and PsO2 data, it is important to attache MAX30102 to the finger without moving or shifting.
Central consists of XIAO_BLE, XIAO_Expansion_Board and a 3.7V 2000mAh battery. It detects “right side down”, “left side down”, “on the back”, and “get up” sleeping postures from Roll and Pitch data. Heart rate, SpO2, and battery voltage are displayed along with the pulse waveform. With an optional switch, Roll, Pitch, sleeping Posture, Heart rate, SpO2, and RSSI can be displayed. And Time, Heart rate, SpO2, and sleeping Posture are recorded on an SD card for further analysis on a PC.
A small modification is required to read the battery voltage connected to the XIAO_Expansion_Board.
nRF52_XIAO_mbed_SleepingMonitor.zip (26.4 KB)
The following libraries were downloaded using the Library Manager. Special thanks to the creators of the libraries.
1.Board Service Package : Seeed nRF52 mbed-enable Borads by Seeed Studio Version 2.9.1
Note: To work around a bug in analogRead() that reads the battery voltage, the patch in the link below is required
“XIAO_BLE_Sense(mbed 2.7.2) battery charge and voltage monitor, analogRead(P0_31) does not work - #31 by msfujino”
2.ArduinoBLE by Arduino Version 1.3.1
Note: Using version 1.3.2 conflicts with XIAO_ESP32C3 compiler
3.Adafruit GFX Library by Adafruit Version 1.11.4
4.Adafruit SSD1306 by Adafruit Version 2.5.7
5.RingBuf by D.Aaron Wisner Version 2.0
6.Madgwick by Arduino Version 1.2.0
7.Seeed Arduino LSM6DS3 by Seeed Studio Version 2.0.3
8.SparkFun MAX3010x Pulse and Proximity Sensor Library by SparkFun Electronics Version 1.1.1