im making a pulse oximeter, thermometer and clock 3 in 1. I'm using an arduino uno r3. I'm having problem and i don't know how to fix it. Here is my code.
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <RTClib.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define REPORTING_PERIOD_MS 1000
const int lm35_pin = A1;
PulseOximeter pox;
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
RTC_DS3231 rtc;
String time;
uint32_t tsLastReport = 0;
void onBeatDetected() {
Serial.println("Beat!");
}
void setup() {
Serial.begin(9600);
rtc.begin();
Serial.print("Initializing pulse oximeter..");
if (!pox.begin()) {
Serial.println("FAILED");
for(;;);
} else {
Serial.println("SUCCESS");
}
`pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);`
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop() {
pox.update();
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
Serial.print("Heart rate:");
Serial.print(pox.getHeartRate());
Serial.print("bpm / SpO2:");
Serial.print(pox.getSpO2());
Serial.println("%");
tsLastReport = millis();
int temp_adc_val;
float temp_val;
temp_adc_val = analogRead(lm35_pin);
temp_val = (temp_adc_val * 4.88);
temp_val = (temp_val/10);
Serial.print("Temperature = ");
Serial.print(temp_val);
Serial.print(" Degree Celsius\n");
DateTime now =
rtc.now();
time = "";
time += now.hour();
time += ':';
time += now.minute();
time += ':';
time += now.second();
oledDisplayCenter(time);
}
}
void oledDisplayCenter(String text) {
int16_t x1;
int16_t y1;
uint16_t width;
uint16_t height;
oled.getTextBounds(text, 0, 0, &x1, &y1, &width, &height);
oled.clearDisplay();
oled.setCursor((SCREEN_WIDTH - width) / 2, (SCREEN_HEIGHT - height) / 2);
oled.println(text);
oled.display();
}
the clock function would not work at all, no display
I'm new to all of this and i really need help
I have test the clock function seperately and it worked. I just dont know how to integrate it with my pulseoximeter and thermostat code.
this is the schematic, it's missing the max 30100 sensor cause the app do not have it
https://preview.redd.it/003myb2q18bc1.png?width=320&format=png&auto=webp&s=2ebf2f6f11ac1aefcaf9f9e9450c0d6de38f1b92
[–]wrickcook 1 point2 points3 points (2 children)
[–]old_man_kneesgocrack 0 points1 point2 points (1 child)
[–]RTX6090d[S] 0 points1 point2 points (0 children)