Function operates only one time or endless

good day.

i'm making SPO2 , heartrate and temperature measures. and sending them with loacation coordinates to web server.
but the spo2/heartrate function which is using max30100 excutes only one time then it keeps the same output varaibles. i've tried to reset the spo2 and heartrate at each loop. it worked but the excution is now trabbed only in the spo2 function . it's not excuting any other part of the code. what shold i do? my complete code is below

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <OneWire.h> 
#include <DallasTemperature.h>
#include "MAX30100_PulseOximeter.h"
#include<SoftwareSerial.h> 
#include <DFRobot_SIM808.h>


#define REPORTING_PERIOD_MS     1000

PulseOximeter pox;

uint32_t tsLastReport = 0;

#define rxPin 11
#define txPin 10

 SoftwareSerial mySerial(txPin, rxPin);
 DFRobot_SIM808 sim808(&mySerial);
 char wlat[12];
 char wlon[12];
 char wwspeed[12];

 String stat1=" normal ";




int32_t spo2; //SPO2 value
int32_t heartRate; //heart rate value
float TMP;
int8_t VheartRate; //heart rate value
int32_t Vspo2; //SPO2 value

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

#define ONE_WIRE_BUS A0
OneWire oneWire(ONE_WIRE_BUS);  
DallasTemperature sensors(&oneWire);

void onBeatDetected()
{
    Serial.println("Beat!");
    heartRate=0;
      spo2=0;
}

void setup()
{
  delay(100);
  Serial.begin(115200);  

 
  //Configure sensor with these setting  
  mySerial.begin(9600);

  Serial.println("Starting...");
 // 
 while(!sim808.init()) 
  {
      delay(1000);
      Serial.print("Sim808 init error\r\n");
  }
  //************* Turn on the GPS power************
  if( sim808.attachGPS())
   {
     Serial.println("Open the GPS power success");
   }
   else 
   {
     Serial.println("Open the GPS power failure");
   }



   lcd.init();                      // initialize the lcd 
  sensors.begin();  
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(1,0);
  lcd.print("Remote vitals");
  lcd.setCursor(1,1);
  lcd.print("monitoring");
  delay(2000);
  lcd.clear();
      if (!pox.begin()) {
        Serial.println("FAILED");
        for(;;);
    } else {
        Serial.println("SUCCESS");
    }


     pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

    // Register a callback for the beat detection
    pox.setOnBeatDetectedCallback(onBeatDetected);
}

int k=0;


void loop()
{
   
 
  if(sim808.getGPS()) {
   Serial.print(sim808.GPSdata.year);
   Serial.print("/");
   Serial.print(sim808.GPSdata.month);
   Serial.print("/");
   Serial.print(sim808.GPSdata.day);
  Serial.print(" ");
   Serial.print(sim808.GPSdata.hour);
   Serial.print(":");
  Serial.print(sim808.GPSdata.minute);
  Serial.print(":");
  Serial.print(sim808.GPSdata.second);
  Serial.print(":");
  Serial.println(sim808.GPSdata.centisecond);
  
  
 
   //Serial.print("latitude :");
   //Serial.println(sim808.GPSdata.lat,6);

 /* sim808.latitudeConverToDMS();
  Serial.print("latitude :");
  Serial.print(sim808.latDMS.degrees);
  Serial.print("\^");
  Serial.print(sim808.latDMS.minutes);
  Serial.print("\'");
  Serial.print(sim808.latDMS.seconeds,6);*/
  //Serial.println("\"");
 /* Serial.print("longitude :");
  Serial.println(sim808.GPSdata.lon,6);
  sim808.LongitudeConverToDMS();
 Serial.print("longitude :");
 Serial.print(sim808.longDMS.degrees);
 Serial.print("\^");
 Serial.print(sim808.longDMS.minutes);
 Serial.print("\'");
 Serial.print(sim808.longDMS.seconeds,6);
//Serial.println("\"");

 //Serial.print("speed_kph :");
 //Serial.println(sim808.GPSdata.speed_kph);
//Serial.print("heading :");
 //Serial.println(sim808.GPSdata.heading);*/
 
 
    float la = sim808.GPSdata.lat;
    float lo = sim808.GPSdata.lon;
    float ws = sim808.GPSdata.speed_kph;


 SubmitHttpRequest(la,lo,ws);
 
 Temperature();

    spo(); 

  
     
        
       }


while(spo2 < 50)
{
spo();
delay(10);

}
 

  
}


void spo(void)
{



    // Make sure to call update as fast as possible
    
         pox.update();
       //tsLastReport = millis();
       if (millis() - tsLastReport > REPORTING_PERIOD_MS)
        {
        
        spo2=pox.getSpO2();
        Serial.println(spo2);
        heartRate=pox.getHeartRate();
        Serial.println(heartRate);
        tsLastReport = millis();
        }



    // Asynchronously dump heart rate and oxidation levels to the serial
    // For both, a value of 0 means "invalid"
    
 
      if(spo2 <100 && spo2 >70)
      {
       Vspo2= spo2;        
      lcd.setCursor(8,0);
      lcd.print("SPO2: ");
      lcd.print(spo2);
      
      }
      if(spo2 ==100)
      {
       Vspo2=spo2;
       lcd.setCursor(8,0);
       lcd.print("SPO2:");
       lcd.print(spo2); 
       
      }

       

  if(heartRate >40 && heartRate <100)
      {
       VheartRate=heartRate;        
      lcd.setCursor(1,1);
      lcd.print("heart rate:  ");
      lcd.print(heartRate);
     // Serial.println(VheartRate);      
         
      }
  else if (heartRate >=100 && heartRate <150)
     {
      VheartRate=heartRate;
      lcd.setCursor(1,1);
      lcd.print("heart rate: ");
      lcd.print(heartRate); 
    // Serial.println(VheartRate);       
     }

       
  if ((TMP < 32 )|| (Vspo2 < 80) || (VheartRate <45))
      {
         stat1 = "critical";
         //Serial.println("critical");                 
      } 
      
      
   
   }

   void Temperature(void)
   {
      sensors.requestTemperatures();
     lcd.setCursor(0,0);
     lcd.print("T=");
     TMP= sensors.getTempCByIndex(0);
      lcd.print(TMP); 
     lcd.print("C");
   }


void SubmitHttpRequest(float la,float lo, float ws)
 {
  
  dtostrf( la,6, 6, wlat); 
  dtostrf( lo,6, 6, wlon); 
  dtostrf( ws,6, 6, wwspeed); 

 mySerial.println("AT");
delay(100);
//ShowSerialData();

mySerial.println("AT+CREG?");
 delay(100);
 //ShowSerialData();

mySerial.println("AT+CSQ");
delay(100);
//ShowSerialData();

mySerial.println("AT+CGATT?");
delay(100);
//ShowSerialData();

 mySerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
 delay(500);
 //ShowSerialData();

 mySerial.println("AT+SAPBR=3,1,\"APN\",\"Etisalat\"");
 delay(500);
 //ShowSerialData();

 mySerial.println("AT+SAPBR=1,1");
 delay(500);
//ShowSerialData();

mySerial.println("AT+SAPBR=3,1");
delay(500);
//ShowSerialData();

mySerial.println("AT+SAPBR=2,1");
delay(500);
//ShowSerialData();

mySerial.println("AT+HTTPINIT"); 
delay(500); 
//ShowSerialData();

mySerial.println("AT+HTTPPARA=\"CID\",1");
delay(500); 
//ShowSerialData();

mySerial.println("AT+HTTPSSL=0");    
//ShowSerialData();
delay(500);

mySerial.println("AT+HTTPSSL=1");
delay(500); 
//ShowSerialData();

mySerial.print("AT+HTTPPARA=\"URL\",\"gpstest.edafait.com/gps/addnew?lat=&lon=&time_date=16/11/2022&o2=&heart_rate=&temperature=&status=&hospital=hos1");
mySerial.print("&lat=");  // This is the value name
mySerial.print(wlat); // value of...
mySerial.print("&lon=");  // This is the value name
mySerial.print(wlon); // value of...
mySerial.print("&o2=");  // This is the value name
mySerial.print(Vspo2); // value of...
mySerial.print("&heart_rate=");  // This is the value name
mySerial.print(VheartRate); // value of...
mySerial.print("&temperature=");  // This is the value name
mySerial.print(TMP);  // This is the value name
mySerial.print("&status=");  // This is the value name
mySerial.print(stat1);  // This is the value name


//mySerial.print("AT+CGSN");
mySerial.print("&time=");  // This is the value name

 mySerial.print("AT+CGMM");

 mySerial.println("\"");
 delay(500);
 //ShowSerialData();



 mySerial.println("AT+HTTPACTION=2");//submit the request 
delay(500);
//ShowSerialData();

mySerial.println("AT+HTTPACTION=1");//submit the request 
delay(500);
//ShowSerialData();

 mySerial.println("AT+HTTPACTION=0");//submit the request 
 delay(500);
 //ShowSerialData();

 mySerial.println("AT+HTTPACTION=0");//submit the request 
delay(500);;
//ShowSerialData();

mySerial.println("AT+HTTPREAD");// read the data from the website you access
delay(300);
//ShowSerialData();


mySerial.println("");
delay(100);

 }

 void ShowSerialData()
 {
   while(mySerial.available()!=0)
     {
       Serial.write(mySerial.read());
     }

 } 

Did you try adding Serial.prints to see what's going on?


void loop()
{

bool doesitdothegetgpsthing = sim808.getGPS();
Serial.println( doesitdothegetgpsthing );// does that print a bunch of 0's or 1's
  if ( doesitdothegetgpsthing ) {

You can remove them after finding the issue.

i would write a separate program that just exercises the SPO2 devices and to understand how they need to be used