How to combine program MAX30100 with program Load Cell HX711?

Can someone help me how to combine 2 coding for max30100 with Load Cell HX711. I already try but when upload only Load Cell HX711 sensor function.

This program MAX30100
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"

#define REPORTING_PERIOD_MS     1000

// PulseOximeter is the higher level interface to the sensor
// it offers:
//  * beat detection reporting
//  * heart rate calculation
//  * SpO2 (oxidation level) calculation
PulseOximeter pox;

uint32_t tsLastReport = 0;

// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
    Serial.println("Beat!");
}

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

    Serial.print("Initializing pulse oximeter..");

    // Initialize the PulseOximeter instance
    // Failures are generally due to an improper I2C wiring, missing power supply
    // or wrong target chip
    if (!pox.begin()) {
        Serial.println("FAILED");
        for(;;);
    } else {
        Serial.println("SUCCESS");
    }

    // The default current for the IR LED is 50mA and it could be changed
    //   by uncommenting the following line. Check MAX30100_Registers.h for all the
    //   available options.
     pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

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

void loop()
{
    // Make sure to call update as fast as possible
    pox.update();

    // Asynchronously dump heart rate and oxidation levels to the serial
    // For both, a value of 0 means "invalid"
    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();
    }
}

This program Load Cell HX711
#include <HX711.h>

HX711 scale(6, 7); //Load Cell DT 6, SCK 7
float calibration_factor = -423; //Load Cell
float units; //Load Cell
float ounces; //Load Cell

void setup ()
{
  Serial.begin(9600);
  scale.set_scale(calibration_factor);
  scale.tare();
}

void loop ()
{
    units = scale.get_units(),10;
  if (units < 0)
  {
    units = 0.00;
  }
  ounces = units * 0.035274;
      Serial.print("Berat:");
      Serial.print(units);
      Serial.println(" g");
}

Please help me....

Hi dery,

well done posting code as code-sections.

google is always worth a 5 minute search

www.google.de/search?lr=&newwindow=1&as_qdr=all&ei=nlkSYIfUF4jCUsCwloAN&q=arduino+combine+two+sketches

www.google.de/search?lr=&newwindow=1&as_qdr=all&ei=7lsSYKLrKuTTgwed4IyIDQ&q=arduino+merge+sketch

This will get you started.
After reading this, there still will be questions left but if your next question is based on the descriptions given above
everybody can see that you put some own effort in learning it.

You seem to be a real beginner. Combining two sketches needs a bit more than just copy & paste to the right place.
What if the two sketches want to use the same IO-Pins for different sensors?
There must be made some more adaptions.
So Take a look into this tutorial:

Arduino Programming Course

It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.

best regards Stefan

Thank you for your information. But, this problem is not working for sensor max30100. Because max30100 not read in serial monitor arduino ide, what if program max30100 and program load cell hx711 combine in one sketch. then, i don't know about it. Please help me...

If watch at least one video on how to do it or read one text how to do it and come back with a concrete question I will help

google is always worth a 5 minute search

www.google.de/search?lr=&newwindow=1&as_qdr=all&ei=nlkSYIfUF4jCUsCwloAN&q=arduino+combine+two+sketches

www.google.de/search?lr=&newwindow=1&as_qdr=all&ei=7lsSYKLrKuTTgwed4IyIDQ&q=arduino+merge+sketch

Oke, i've done, thanks for your information :smiley:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.