Alamat
Tampin, 73000 Negeri Sembilan
Waktu Bekerja
Isnin to Jumaat: 8AM - 6PM
Alamat
Tampin, 73000 Negeri Sembilan
Waktu Bekerja
Isnin to Jumaat: 8AM - 6PM

heart rateheart rateHeart Beat Monitoring System adalah projek yang memantau denyutan jantung seorang manusia dan seterusnya memaparkan pada display. Paparan display adalah menerusi PC (web browser).
Komponen yang diperlukan :
Secara ringkasnya adalah seperti rajah di bawah:

Pertama sekali mulakan dengan sambungan litar :

| NodeMCU | MAX30100 | OLED |
|---|---|---|
| 3.3v | VCC | VCC |
| GND | GND | GND |
| D1 | SCL | SCL |
| D2 | SDA | SDA |
Seterusnya, program ditulis menggunakan Arduino IDE. Sebelum menulis program, library berikut perlu diinstall terlebih dahulu:
Code untuk NodeMCU dengan menggunakan Arduino IDE adalah seperti berikut:
[cpp]
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include "SSD1306.h"
#define REPORTING_PERIOD_MS 1000
// PulseOximeter is the higher level interface to the sensor
// it offers:
// * beat detection reporting
// * heart rate calculation
// * SpO2 (oxidation level) calculation
// * pin connection 4(SDA) and 5(SCL)
PulseOximeter pox;
// D4 -> SDA
// D5 -> SCL
SSD1306 display(0x3c, D2, D1);
uint32_t tsLastReport = 0;
volatile boolean heartBeatDetected = false;
// Callback method will be fired when a pulse is detected
void onBeatDetected() {
heartBeatDetected = true;
//Serial.println("Beat!");
}
void setup() {
Serial.begin(115200);
//Serial.print("Initializing pulse oximeter..");
// Initialize the PulseOximeter instance and register a beat-detected callback
pox.begin();
// 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.init();
display.setFont(ArialMT_Plain_16);
}
void loop() {
// Make sure to call update as fast as possible
pox.update();
// Asynchronously dump heart rate and oxidation levels to the serial
// For both, a value of 0 means "invalid"
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
float bpm = pox.getHeartRate();
float spO2 = pox.getSpO2();
//float temp = pox.getTemperature();
//Serial.print("Heart rate:");
//Serial.print(bpm);
//Serial.print("bpm / SpO2:");
//Serial.print(spO2);
//Serial.println("%");
tsLastReport = millis();
// If the values are valid and heart beat detected, publish to Firebase
if (heartBeatDetected && bpm != 0) {
display.clear(); //have to clear display first
display.drawString(0, 0, "HR: " + String(bpm) + " bpm");
display.drawString(0, 20, "SpO2: " + String(spO2) + " %");
//display.drawString(0, 40, "Temp: " + String(temp) + " C");
display.display();
Serial.println(String(bpm) + "|" + String(spO2) + "|");
} else {
display.clear();
display.display();
}
}
}
[/cpp]

Bersambung …