oxullo / Arduino-MAX30100

Arduino library for MAX30100, integrated oximeter and heart rate sensor
GNU General Public License v3.0
192 stars 135 forks source link

When call pox.update() in the loop, Arduino don't read Serial data from RX pin #80

Closed robertomaster closed 4 years ago

robertomaster commented 4 years ago

Hello friends of the community. I facing this error a quite long time and I hope you can help me.

When I call the pox.update() method into loop, the Arduino don't receive the entire data from Serial port, who it's connected to a HC-05 bluetooth module. But when I comment it, Arduino receive the data quite well. The variable "palabra" store the data from Serial.

The data of my sensor from the Tester example:

Initializing MAX30100..Success Enabling HR/SPO2 mode..done. Configuring LEDs biases to 50mA..done. Lowering the current to 7.6mA..done. Shutting down..done. Resuming normal operation..done. Sampling die temperature..done, temp=34.75C All test pass.

Press any key to go into sampling loop mode

My setup:

My Arduino code:

void loop() {
  if (Serial.available() > 0) {
    char incomingByte = Serial.read();
    if (incomingByte == 'T') {
      palabra = getStringfromProgMem(3);
      c = 0;
    } else {
      palabra += incomingByte;
    }
  }

  display.clearDisplay();
  pox.update();
  estado ? (enlace()) : (noenlace());
  unsigned long tiempoActual = millis();
  if (tiempoActual - tiempoAnterior >= intervaloEvento) {
    rate = pox.getHeartRate();
    spo = pox.getSpO2();
    if (rate && palabra != getStringfromProgMem(3)) {
      c++;
    }
    if (c == 60) {
      c = 0;
    }
    Serial.print(rate);
    Serial.print(',');
    Serial.print(spo);
    Serial.print(',');
    Serial.println(c);
    tiempoAnterior = tiempoActual;
  }
  mostrar(rate, 15, 35);
  mostrar(spo, 105, 35);
  mostrar(getStringfromProgMem(0), 10, 52);
  mostrar(getStringfromProgMem(1), 100, 52);

  display.display();

  estado = digitalRead(STATE);
}
NageshPatil321 commented 2 years ago

hi, how can you solve this problem and please share me your logic because of this issue i also stuck in my project but i am using MAX30100 sensor instade of HC-05 . please help me

robertomaster commented 2 years ago

Hi NageshPatil321,

I send you the functional code that I arrived to run just fine. You must optimize your code; because of the MAX30100 library size your Arduino is going to freeze all time (even worse if you use an Arduino UNO or smaller), and that's the reason for the issue you stock on. I use pointers and other methods to optimize my code as you're gonna see in my ".ino" file.

Recommendation: you must use the interruptions pin of the sensor to write your code, it's the best approach.

I hope I helped.

Greetings.

Roberto.

On Tue, Sep 27, 2022 at 6:54 PM NageshPatil321 @.***> wrote:

hi, how can you solve this problem and please share me your logic because of this issue i also stuck in my project but i am using MAX30100 sensor instade of HC-05 . please help me

— Reply to this email directly, view it on GitHub https://github.com/oxullo/Arduino-MAX30100/issues/80#issuecomment-1259854675, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK6SZTTLZC3R3HICDNUFFWDWAMYELANCNFSM4S3SOPKQ . You are receiving this because you modified the open/close state.Message ID: @.***>

thewackyseal commented 2 years ago

@robertomaster Hi, would you mind sharing a copy of your code with me too? I am having the same issue. Thank you in advance.

robertomaster commented 2 years ago

Hi thewackyseal, sorry for the delay.

Greetings.

Roberto.

On Fri, Sep 30, 2022 at 8:37 AM thewackyseal @.***> wrote:

@robertomaster https://github.com/robertomaster Hi, would you mind sharing a copy of your code with me too? I am having the same issue. Thank you in advance.

— Reply to this email directly, view it on GitHub https://github.com/oxullo/Arduino-MAX30100/issues/80#issuecomment-1263217931, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK6SZTWFR7DBYWLZHHMQFQ3WA2KB5ANCNFSM4S3SOPKQ . You are receiving this because you were mentioned.Message ID: @.***>

thewackyseal commented 2 years ago

Hi Roberto,

I am not sure where to find your code, I am unable to find it in email or in github. Would you mind sending it again and mentioning where it is? I am lost.

Thank you, thewackyseal

On Sun, Oct 2, 2022 at 11:52 PM robertomaster @.***> wrote:

Hi thewackyseal, sorry for the delay.

Greetings.

Roberto.

On Fri, Sep 30, 2022 at 8:37 AM thewackyseal @.***> wrote:

@robertomaster https://github.com/robertomaster Hi, would you mind sharing a copy of your code with me too? I am having the same issue. Thank you in advance.

— Reply to this email directly, view it on GitHub < https://github.com/oxullo/Arduino-MAX30100/issues/80#issuecomment-1263217931 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AK6SZTWFR7DBYWLZHHMQFQ3WA2KB5ANCNFSM4S3SOPKQ

. You are receiving this because you were mentioned.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/oxullo/Arduino-MAX30100/issues/80#issuecomment-1264674180, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARL2FB3Y5DZJYAYOYDUADZLWBGVSJANCNFSM4S3SOPKQ . You are receiving this because you commented.Message ID: @.***>

robertomaster commented 2 years ago

Tesis.zip Hi, I'm sended you a mail with the code. But I attach the ZIP file with my logic.

Greetings.

Valenmonx3 commented 1 year ago

I solved this problem with this lines in the loop.

if (millis() - tsLastReport1 >= 75) { tsLastReport1 = millis(); pox.update(); }