This is an old revision of the document!
Author: Ana-Maria Cretan
Master: AAC
The goal of this project is to create a real-time pulse and oxygen level monitor platform using an ESP32 board and MAX30100 sensor. The data provided by the sensor will be displayed in the Adafuit IO interface and interpreted by two flag indicators. The indicators aim to translate the values of the pulse and oxygen level into a simple good(green)/bad(red) lamp indication. If the registered values are out of the normal range, an e-mail alert will be sent to the user/user`s contacts.
In the hardware diagram we used the following components:
The main functionality of the code is displayed by the following diagram. The setup() function is executed first and is used to enable the wi-fi connection, connect to the MQTT client, and config the pulse sensor.
In the setup section of the code, the Wi-Fi connection is established, followed by the MQTT connection for the web application and the configuration of the pulse sensor. During the loop section, the connection to the MQTT client is checked first along with the switch state from the application. The data published to the web display can we stopped at any time (while connected) by turning the switch block off.
The code is developed using Arduino IDE,and the following libraries:
Library | Description |
---|---|
stdint.h | for intermediary variables and calculus |
Wire.h | for the pulse sensor connection |
WiFi.h | to establish the WiFi connection of the ESP32 board |
Adafruit_MQTT.h | used for connection with the web interface |
Adafruit_MQTT_Client.h | to establish the client connection for data publish |
MAX30100_PulseOximeter.h | for interfering with the pulse sensor |
The sensor data read and the publish to the MQTT client are split into tasks.For the sensor read, we use update() from the Max30100 library and getHeartRate()/pox.getSpO2 to obtain the actual values. Before they are published we test if the recorded values are in the normal range:
if (BPM == 0){ //Asystole: flat linig BPMState_ns = "Asystole"; }else if(BPM != 0 && BPM <= 40){ //Idioventricular Rhythm: Heart rate between 20 - 40 BPM BPMState_ns = "Idioventricular Rhythm"; } else if(BPM > 40 && BPM <= 60){ //Junctional Escape Rhythm: Heart rate 40 - 60 BPM BPMState_ns = "Junctional Escape Rhythm"; } else if(BPM > 60 && BPM <= 120){ //Normal: Heart rate 60 - 100 BPM BPMState_ns = "Normal"; } else if(BPM >= 121){ //Tachycardia: Heart rate >= 100 BPM BPMState_ns = "Tachycardia"; };
* for the Oxigen level the interpretation is into the interface block