-2

I'm sharing my code.. The problem I am facing is that the code performs all the functions that are to be called except showing the MAX30100 (for heart rate) readings. I have tried this code using statement switches,cases, if-else but couldn't figure out. Can anyone help me out regarding this?

    unsigned long runGSR() {          

total = total - readings[index];         // subtract the last reading:

 readings[index] = analogRead(inputPin);  // read from the sensor:

  delay(100);

  total = total + readings[index];       // add the reading to the total:

  index = index + 1;                     // advance to the next position in the 

array:

  if (index >= numReadings)               //when the end of the array is reached

    index = 0;                           // wrapped around to the beginning:


  average = total / numReadings;           // calculate the average:

  return average;       // send it to the computer as ASCII digits


    } 
    void ambtemp()    

    {

       reading = analogRead(A2);       //takes the reading from analogue pin 2

  tempVolts = reading * 5.0 / 1024.0;   //converts the readings to volts

  ambitemp = tempVolts / 0.01;        //output voltage /10 millivolts = 1 degree 
C

  Serial.print(",Ambient Temp:");      //prints ambient temperature in serial monitor

  Serial.println(ambitemp);

  delay(10);         

    }

    void hbt()    //Function for heart rate (MAX30100) in which I am having problem
    {
        do
        {
            pox.update(); // Make sure to call update as fast as possible
            if (millis() - tsLastReport > REPORTING_PERIOD_MS) {   //the loop repeats every second 
            lcd.clear();
            Serial.print("HR:");
            Serial.println(pox.getHeartRate()); //prints Heart rate on LCD 
            delay(100);
            ambtemp();    //calls the ambient temperature function
            gsr = runGSR();   //calls the GSR sensor function 
            delay(100);
            tsLastReport = millis();
        }
  • 1
    You have two missing } Add them then use ctrl+t in ArduinoIDE to automatically format your code and then paste it again please. (Please use "code" function of the stackexchange editor to add code as code) – Filip Franik Feb 11 at 13:57
  • I try it but it doesn't work. – Sannay Feb 11 at 14:37
  • Any other solution... there is some kind of bug that is not plotting the readings of MAX30100 – Sannay Feb 11 at 14:39
  • What I meant was "Show us your complete code in a way that we can run it on our Arduino simulators" Right now the code you pasted in the question does not compile. No one can help you right now. (You can Edit the question and change the code to the complete one) – Filip Franik Feb 11 at 14:40
  • Serial.println(pox.getHeartRate()); //prints Heart rate on LCD .... the comment does not match the command – jsotola Feb 11 at 17:10
1

I assume you use this as source for your code:

This means that:

#include "MAX30100_PulseOximeter.h"
PulseOximeter pox;

Your issue is that the line:

Serial.println(pox.getHeartRate()); //prints Heart rate on LCD

Does not actually print anything on the LCD. It only shows the value on the serial.

Try using lcd.print()

  • No, its neither print value on lcd nor on serial ide. – Sannay Feb 11 at 15:02
  • Paste your entire code in the question please. – Filip Franik Feb 11 at 15:09
  • Done. check now please – Sannay Feb 11 at 18:03
  • There are many many errors in your code. According to StackExchange rules you should provide a Minimal, Complete, and Verifiable example stackoverflow.com/help/mcve that allows other people check for solution to your problem. Your example still does not compile and I can't test it. – Filip Franik Feb 11 at 19:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.