Pulse oximeter sensor w/ Blynk not working

In this setup, I have a SparkFun Pulse Oximeter sensor connected to Arduino Uno (I2C protocol) and am using the USB connection for Blynk (for iOS device). Without Blynk code, the sensor gets configured and proper values are displayed on LCD & serial monitor. However, adding/playing around with Blynk code, I am not able to configure the sensor to be able to read any values onto the Blynk virtual pins. So - I know the Hardware is ok; it’s something in the Blynk code that is not configuring the sensor properly (probably not sequenced right). Here is the sketch for this:

#define BLYNK_PRINT DebugSerial
                                         
#include <SparkFun_Bio_Sensor_Hub_Library.h>

//#include <SerLCD.h> //Click here to get the library: http://librarymanager/All#SparkFun_SerLCD
//SerLCD lcdnew; // Initialize the library with default I2C address 0x72
#include <Wire.h>

// No other Address options.
#define DEF_ADDR 0x55

// Reset pin, MFIO pin (for pulse oximeter sensor)
const int resPin = 4;
const int mfioPin = 5;

unsigned long clocktime;

// Takes address, reset pin, and MFIO pin.
SparkFun_Bio_Sensor_Hub bioHub(resPin, mfioPin);

bioData body;

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "V9AyXp20HLhJmXzYh3nnx330TUJmA5V8";

BlynkTimer timer;

void sendSensor() {

  int result = bioHub.begin();
    
  if (!result)
    Serial.println("Pulse Oximeter Sensor started!");
  else
    Serial.println("Could not communicate with the sensor!!!");

  Serial.println("Configuring Pulse Oxismeter Sensor...."); 
  int error = bioHub.configBpm(MODE_ONE); // Configuring just the BPM settings. 
  if(!error){
    Serial.println("Pulse Oximeter Sensor configured.");
  }
  else {
    Serial.println("Error configuring Pulse Oximeter sensor.");
    Serial.print("Error: "); 
    Serial.println(error); 
    digitalWrite(9, HIGH);
  }

// Information from the readBpm function will be saved to our "body"
// variable.
body = bioHub.readBpm();

    if (body.status == 3 && body.confidence > 90) { 
      Blynk.virtualWrite(V0, body.heartRate);
      Blynk.virtualWrite(V1, body.oxygen);
    }
/*    else {
      digitalWrite(13, HIGH); // turn-off the blue LED once a good reading is detected & finger is off the sensor
      lcdnew.print("Oximeter: Finger");
      lcdnew.setCursor(0, 1);
      lcdnew.print("Not Detected");
    } */
//  delay(500); // Slowing it down
}

void setup(){ 

  DebugSerial.begin(9600);
  Serial.begin(9600);
 
  Blynk.begin(Serial, auth);
  bioHub.begin(); 
  timer.setInterval(1000L, sendSensor);
}

void loop(){
    Blynk.run();
    timer.run();
}

Your serial ports are all messed-up.

Whatever you are using for your USB connection needs to be used for that and that alone.

Pete.

Thanks Pete. I was using that to debug on serial monitor by commenting the Blynk code. I removed the serial print statements and still have the same issue. Somehow, the sensor is getting blocked in these Blynk calls and I am not sure how all that works.

Any suggestions on what to change in the code to get the sensor configured?

Yes, post your actual code, details of what you have connected to where, what you are seeing in your serial monitor (if you have an FTDI) and exactly what symptoms you are experiencing.

Pete.

Here is the code that works in initializing the sensor (without Blynk code):

#include <SparkFun_Bio_Sensor_Hub_Library.h>

//#include <SerLCD.h> //Click here to get the library: http://librarymanager/All#SparkFun_SerLCD
//SerLCD lcdnew; // Initialize the library with default I2C address 0x72
#include <Wire.h>

// No other Address options.
#define DEF_ADDR 0x55

// Reset pin, MFIO pin (for pulse oximeter sensor)
const int resPin = 4;
const int mfioPin = 5;

// Takes address, reset pin, and MFIO pin.
SparkFun_Bio_Sensor_Hub bioHub(resPin, mfioPin);

bioData body;

void sendSensor() {

  int result = bioHub.begin();
    
  if (!result)
    Serial.println("Pulse Oximeter Sensor started!");
  else
    Serial.println("Could not communicate with the sensor!!!");

  Serial.println("Configuring Pulse Oxismeter Sensor...."); 
  int error = bioHub.configBpm(MODE_ONE); // Configuring just the BPM settings. 
  if(!error){
    Serial.println("Pulse Oximeter Sensor configured.");
  }
  else {
    Serial.println("Error configuring Pulse Oximeter sensor.");
    Serial.print("Error: "); 
    Serial.println(error); 
  }

// Information from the readBpm function will be saved to our "body"
// variable.
    body = bioHub.readBpm();

    if (body.status == 3 && body.confidence > 90) { 
      Serial.println("HeartRate: ");
      Serial.print(body.heartRate);
      Serial.println("Oxygen: ");   
      Serial.print(body.oxygen); 
    }
    else {
      Serial.println("Oximeter: Finger Not detected");
    }
  delay(500); // Slowing it down
}

void setup(){ 

  Serial.begin(115200);
  Wire.begin();
 
  bioHub.begin(); 
  sendSensor();
}

void loop(){
    sendSensor();
}

Here is the screen capture of my serial monitor showing the sensor initialization:

The code I had in my earlier post is an attempt to modify to include Blynk to capture data from this sensor. The issue is - I am unable to initialize the sensor in that code.

Please let me know if you need more information.

That means the code where you’ve…

We currently have no idea which serial port you are using for the Blynk connection and which you are using for debugging via an FTFI (if you have one - if you don’t then why are you bothering with the debug output?)

This means nothing to me, details please.

Pete.

Here is my attempt at modifying the sketch (to include Blynk connection thru USB - removing all serial prints). The issue with this that this is not initializing the sensor:


#define BLYNK_PRINT DebugSerial
                                         
#include <SparkFun_Bio_Sensor_Hub_Library.h>

#include <Wire.h>

// No other Address options.
#define DEF_ADDR 0x55

// Reset pin, MFIO pin (for pulse oximeter sensor)
const int resPin = 4;
const int mfioPin = 5;

// Takes address, reset pin, and MFIO pin.
SparkFun_Bio_Sensor_Hub bioHub(resPin, mfioPin);

bioData body;

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "V9AyXp20HLhJmXzYh3nnx330TUJmA5V8";

BlynkTimer timer;

void sendSensor() {

  int result = bioHub.begin();
    
// Information from the readBpm function will be saved to our "body"
// variable.
body = bioHub.readBpm();

    if (body.status == 3 && body.confidence > 90) { 
      Blynk.virtualWrite(V0, body.heartRate);
      Blynk.virtualWrite(V1, body.oxygen);
    }

//  delay(500); // Slowing it down
}

void setup(){ 

  DebugSerial.begin(9600);
  Serial.begin(9600);
 
  Blynk.begin(Serial, auth);
  bioHub.begin(); 
  timer.setInterval(1000L, sendSensor);
}

void loop(){
    Blynk.run();
    timer.run();
}

Here is connection to blynk:
Connecting device at COM7 to blynk-cloud.com:80
OpenC0C("\.\COM7", baud=9600, data=8, parity=no, stop=1) - OK
Connect(“blynk-cloud.com”, “80”) - OK
InOut() START
DSR is OFF


I don’t have FTFI…
Looking for ideas on how to go about debugging this.

How do you know this fact?

Pete.

This particular sensor lights-up (red) when you place your finger on it to determine blood oxygen. And - with Blynk code (above), it doesn’t; without Blynk code, it does and detects values I expect on blood oxygen & HR.

Thanks & appreciate the help/support; I just figured out the issue. I was missing Wire.begin() in the Blynk code to join the I2C bus.