#include <Wire.h> //#include <LiquidCrystalI2C.h> #include <SPI.h> #include…
- User
#include <Wire.h> //#include <LiquidCrystal_I2C.h> #include <SPI.h>
#include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET 4 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define maxperiod_siz 80 // max number of samples in a period #define measures 10 // number of periods stored #define samp_siz 4 // number of samples for average #define rise_threshold 3 // number of rising measures to determine a peak
// a liquid crystal displays BPM //LiquidCrystal_I2C lcd(0x3F, 16, 2);
int T = 20; // slot milliseconds to read a value from the sensor int sensorPin = A1; int REDLed = 10; int IRLed = 11;
int SpO2; int avBPM;
byte sym[3][8] = { { B00000, B01010, B11111, B11111, B01110, B00100, B00000, B00000 },{ B00000, B00000, B00000, B11000, B00100, B01000, B10000, B11100 },{ B00000, B00100, B01010, B00010, B00100, B00100, B00000, B00100 } };
void setup() { Serial.begin(9600); Serial.flush(); pinMode(sensorPin,INPUT); pinMode(REDLed,OUTPUT); pinMode(IRLed,OUTPUT);
// initialize the LCD // lcd.init(); // lcd.backlight();
// turn off leds digitalWrite(REDLed,LOW); digitalWrite(IRLed,LOW);
// for(int i=0;i<8;i++) lcd.createChar(i, sym[i]); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32 Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever
}}
void loop () { /*display.clearDisplay(); display.setTextSize(1); // Draw 2X-scale text display.setTextColor(SSD1306_WHITE); display.setCursor(20, 10); display.println("Insert Fingure");
display.display(); */ bool finger_status = true;
float readsIR[samp_siz], sumIR,lastIR, reader, start; float readsRED[samp_siz], sumRED,lastRED;
int period, samples; period=0; samples=0; int samplesCounter = 0; float readsIRMM[maxperiod_siz],readsREDMM[maxperiod_siz]; int ptrMM =0; for (int i = 0; i < maxperiod_siz; i++) { readsIRMM[i] = 0;readsREDMM[i]=0;} float IRmax=0; float IRmin=0; float REDmax=0; float REDmin=0; double R=0;
float measuresR[measures]; int measuresPeriods[measures]; int m = 0; for (int i = 0; i < measures; i++) { measuresPeriods[i]=0; measuresR[i]=0; }
int ptr;
float beforeIR;
bool rising; int rise_count; int n; long int last_beat; for (int i = 0; i < samp_siz; i++) { readsIR[i] = 0; readsRED[i]=0; } sumIR = 0; sumRED=0; ptr = 0;
while(1) {
code - Assistant
- User
I made a pulse oximeter and instead of using Max 30100 I’m using 2 leds (1 red and 1 IR 940 nm sender) and one photodiode 940 nm receiver and I’m using Arduino pro mini (pin A1 is assigned to analog signal input from photodiode and pin 10 and 11 are connected to base of BC547 Transistors with two 4.7k ohm resistors) and O’LED 0.96 ssd 1306 for display( SDA and SCL are connected to A4 and A5 of arduino pro) my power supply is 9v DC battery with a LM7805 and also pins for IR and Red led are connected to two bases of BC547 with a 4.7 k Ohm resistors and also the collector pin is connected short leg of LED cathode and Emitter pin is connected to ground and anode of led are connected to 5 v dc and also photodiode is connected to A1 and through a junction is connected to Vcc with a 10 K resistor , I turned it on leds seems to light up and on O’led screen I see word “insert finger” and dosent measure the SPO2 and Heart rate ( in below I put the arduino code) what part I missed and or gone wrong please check my code which I send you earlier and find mistakes
- Assistant
- User
I have a calibration code which is this : // // SATURTION IS A FUNCTION OF R (calibration) // Y = k*x + m // change the value of m increase or decrease it as per your reading // k and m are calculated with another oximeter SpO2 = -19 * R + 99; //
update my code with this and also check for typos and correct them in print and also check the processing and algorithms
- Assistant
- User
ok update my code and give the full code with the answer above in mind
- Assistant