How To Make Pulse Oximeter
Hello friends, this is an Oximeter which measure Oxygen saturation on blood also measure heartbeat rate just using your finger. At this CORONA pandemic pulse Oximeter is very essential to measure heartbeat rate and oxygen saturation. Just follow all the step and make your own Pulse Oximeter.
Components :
- Arduino nano : https://amzn.to/3z8C2IM
- Max 30100 Sensor : https://robu.in/product/max30100-pulse-oximeter-heart-rate-sensor-module/
- Power bank Module : https://amzn.to/3ppeqv1
- SSD 1306 Display : https://robu.in/product/0-96-inch-yellow-yellow-blue-oled-lcd-led-display-module/
Connection Diagram :
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
#include <Wire.h> #include "MAX30100_PulseOximeter.h" #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define ENABLE_MAX30100 1 #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 32 //64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) // The pins for I2C are defined by the Wire-library. // On an arduino UNO: A4(SDA), A5(SCL) // On an arduino MEGA 2560: 20(SDA), 21(SCL) // On an arduino LEONARDO: 2(SDA), 3(SCL), ... #define OLED_RESET 4 // 4 // Reset pin # (or -1 if sharing Arduino reset pin) #define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); #if ENABLE_MAX30100 #define REPORTING_PERIOD_MS 5000 // PulseOximeter is the higher level interface to the sensor // it offers: // * beat detection reporting // * heart rate calculation // * SpO2 (oxidation level) calculation PulseOximeter pox; #endif uint32_t tsLastReport = 0; int xPos = 0; // Callback (registered below) fired when a pulse is detected void onBeatDetected() { Serial.println("Beat!"); heart_beat(&xPos); } void setup() { Serial.begin(115200); Serial.println("SSD1306 128x64 OLED TEST"); // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); for (;;); // Don't proceed, loop forever } // Show initial display buffer contents on the screen -- // the library initializes this with an Adafruit splash screen. //display.display(); display.clearDisplay(); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(20, 18); // Display static text display.print("Pulse OxiMeter"); int temp1 = 0; int temp2 = 40; int temp3 = 80; heart_beat(&temp1); heart_beat(&temp2); heart_beat(&temp3); xPos = 0; display.display(); delay(2000); // Pause for 2 seconds display.cp437(true); display.clearDisplay(); Serial.print("Initializing pulse oximeter.."); #if ENABLE_MAX30100 // Initialize the PulseOximeter instance // Failures are generally due to an improper I2C wiring, missing power supply // or wrong target chip if (!pox.begin()) { Serial.println("FAILED"); for (;;); } else { Serial.println("SUCCESS"); } // The default current for the IR LED is 50mA and it could be changed // by uncommenting the following line. Check MAX30100_Registers.h for all the // available options. pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA); // Register a callback for the beat detection pox.setOnBeatDetectedCallback(onBeatDetected); display_data(0, 0); #endif } void loop() { #if ENABLE_MAX30100 // Make sure to call update as fast as possible pox.update(); int bpm = 0; int spo2 = 0; // Asynchronously dump heart rate and oxidation levels to the serial // For both, a value of 0 means "invalid" if (millis() - tsLastReport > REPORTING_PERIOD_MS) { //Serial.print("Heart rate:"); bpm = pox.getHeartRate(); spo2 = pox.getSpO2(); Serial.println(bpm); //Serial.print("bpm / SpO2:"); Serial.println(spo2); //Serial.println("%"); tsLastReport = millis(); display_data(bpm, spo2); } #endif drawLine(&xPos); } void display_data(int bpm, int spo2) { display.fillRect(0, 18, 127, 15, BLACK); //if(bpm ==0 && spo2==0){ // display.setTextSize(1); // display.setTextColor(WHITE); //display.setCursor(0, 18); // Display static text // display.print("Fingure Out"); //} display.fillRect(0, 18, 127, 15, BLACK); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0, 18); // Display static text display.print("BPM "); display.setTextSize(2); display.print(bpm); display.display(); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(64, 18); // Display static text display.print("Spo2% "); display.setTextSize(2); display.println(spo2); display.display(); } void drawLine(int *x_pos) { // Draw a single pixel in white display.drawPixel(*x_pos, 8, WHITE); display.drawPixel((*x_pos)++, 8, WHITE); display.drawPixel((*x_pos)++, 8, WHITE); display.drawPixel((*x_pos)++, 8, WHITE); display.drawPixel((*x_pos), 8, BLACK); // ----- //Serial.println(*x_pos); display.fillRect(*x_pos, 0, 31, 16, BLACK); display.display(); //delay(1); if (*x_pos >= SCREEN_WIDTH) { *x_pos = 0; } } void heart_beat(int *x_pos) { /************************************************/ //display.clearDisplay(); display.fillRect(*x_pos, 0, 30, 15, BLACK); // Draw a single pixel in white display.drawPixel(*x_pos + 0, 8, WHITE); display.drawPixel(*x_pos + 1, 8, WHITE); display.drawPixel(*x_pos + 2, 8, WHITE); display.drawPixel(*x_pos + 3, 8, WHITE); display.drawPixel(*x_pos + 4, 8, BLACK); // ----- //display.display(); //delay(1); display.drawPixel(*x_pos + 5, 7, WHITE); display.drawPixel(*x_pos + 6, 6, WHITE); display.drawPixel(*x_pos + 7, 7, WHITE); // .~. //display.display(); //delay(1); display.drawPixel(*x_pos + 8, 8, WHITE); display.drawPixel(*x_pos + 9, 8, WHITE); // -- //display.display(); //delay(1); /******************************************/ display.drawPixel(*x_pos + 10, 8, WHITE); display.drawPixel(*x_pos + 10, 9, WHITE); display.drawPixel(*x_pos + 11, 10, WHITE); display.drawPixel(*x_pos + 11, 11, WHITE); //display.display(); //delay(1); /******************************************/ display.drawPixel(*x_pos + 12, 10, WHITE); display.drawPixel(*x_pos + 12, 9, WHITE); display.drawPixel(*x_pos + 12, 8, WHITE); display.drawPixel(*x_pos + 12, 7, WHITE); //display.display(); //delay(1); display.drawPixel(*x_pos + 13, 6, WHITE); display.drawPixel(*x_pos + 13, 5, WHITE); display.drawPixel(*x_pos + 13, 4, WHITE); display.drawPixel(*x_pos + 13, 3, WHITE); //display.display(); //delay(1); display.drawPixel(*x_pos + 14, 2, WHITE); display.drawPixel(*x_pos + 14, 1, WHITE); display.drawPixel(*x_pos + 14, 0, WHITE); display.drawPixel(*x_pos + 14, 0, WHITE); //display.display(); //delay(1); /******************************************/ display.drawPixel(*x_pos + 15, 0, WHITE); display.drawPixel(*x_pos + 15, 1, WHITE); display.drawPixel(*x_pos + 15, 2, WHITE); display.drawPixel(*x_pos + 15, 3, WHITE); //display.display(); //delay(1); display.drawPixel(*x_pos + 15, 4, WHITE); display.drawPixel(*x_pos + 15, 5, WHITE); display.drawPixel(*x_pos + 16, 6, WHITE); display.drawPixel(*x_pos + 16, 7, WHITE); //display.display(); //delay(1); display.drawPixel(*x_pos + 16, 8, WHITE); display.drawPixel(*x_pos + 16, 9, WHITE); display.drawPixel(*x_pos + 16, 10, WHITE); display.drawPixel(*x_pos + 16, 11, WHITE); //display.display(); //delay(1); display.drawPixel(*x_pos + 17, 12, WHITE); display.drawPixel(*x_pos + 17, 13, WHITE); display.drawPixel(*x_pos + 17, 14, WHITE); display.drawPixel(*x_pos + 17, 15, WHITE); //display.display(); //delay(1); display.drawPixel(*x_pos + 18, 15, WHITE); display.drawPixel(*x_pos + 18, 14, WHITE); display.drawPixel(*x_pos + 18, 13, WHITE); display.drawPixel(*x_pos + 18, 12, WHITE); //display.display(); //delay(1); display.drawPixel(*x_pos + 19, 11, WHITE); display.drawPixel(*x_pos + 19, 10, WHITE); display.drawPixel(*x_pos + 19, 9, WHITE); display.drawPixel(*x_pos + 19, 8, WHITE); //display.display(); //delay(1); /****************************************************/ display.drawPixel(*x_pos + 20, 8, WHITE); display.drawPixel(*x_pos + 21, 8, WHITE); //display.display(); //delay(1); /****************************************************/ display.drawPixel(*x_pos + 22, 7, WHITE); display.drawPixel(*x_pos + 23, 6, WHITE); display.drawPixel(*x_pos + 24, 6, WHITE); display.drawPixel(*x_pos + 25, 7, WHITE); //display.display(); //delay(1); /************************************************/ display.drawPixel(*x_pos + 26, 8, WHITE); display.drawPixel(*x_pos + 27, 8, WHITE); display.drawPixel(*x_pos + 28, 8, WHITE); display.drawPixel(*x_pos + 29, 8, WHITE); display.drawPixel(*x_pos + 30, 8, WHITE); // ----- *x_pos = *x_pos + 30; display.display(); delay(1); } |