BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

NodeNCU with MAX30100

hello, this is my first post. I hope someone can help me fix this error in my project.
why Max30100 cannot read BPM & SpO2 after implement with Blynk?

#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#define BLYNK_PRINT Serial
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "Adafruit_GFX.h"
#include "OakOLED.h"

#define REPORTING_PERIOD_MS 1000
OakOLED oled;

char auth[] = "y67ppUqAduYLCfRuwltVPb7mgV-lulsa";             // Authentication Token Sent by Blynk
char ssid[] = "Carvell";        //WiFi SSID
char pass[] = "carvell1234";        //WiFi Password

// Connections : SCL PIN - D1 , SDA PIN - D2 , INT PIN - D0
PulseOximeter pox;

float BPM, SpO2;
uint32_t tsLastReport = 0;

const unsigned char bitmap [] PROGMEM =
{
  0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x18, 0x00, 0x0f, 0xe0, 0x7f, 0x00, 0x3f, 0xf9, 0xff, 0xc0,
  0x7f, 0xf9, 0xff, 0xc0, 0x7f, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xf0,
  0xff, 0xf7, 0xff, 0xf0, 0xff, 0xe7, 0xff, 0xf0, 0xff, 0xe7, 0xff, 0xf0, 0x7f, 0xdb, 0xff, 0xe0,
  0x7f, 0x9b, 0xff, 0xe0, 0x00, 0x3b, 0xc0, 0x00, 0x3f, 0xf9, 0x9f, 0xc0, 0x3f, 0xfd, 0xbf, 0xc0,
  0x1f, 0xfd, 0xbf, 0x80, 0x0f, 0xfd, 0x7f, 0x00, 0x07, 0xfe, 0x7e, 0x00, 0x03, 0xfe, 0xfc, 0x00,
  0x01, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0x3f, 0xc0, 0x00,
  0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

void onBeatDetected()
{
  Serial.println("Beat Detected!");
  oled.drawBitmap( 60, 20, bitmap, 28, 28, 1);
  oled.display();
}

void setup()
{
  Serial.begin(115200);
  oled.begin();
  oled.clearDisplay();
  oled.setTextSize(1);
  oled.setTextColor(1);
  oled.setCursor(0, 0);

  oled.println("Initializing pulse oximeter..");
  oled.display();

  pinMode(16, OUTPUT);
  Blynk.begin(auth, ssid, pass);  

  Serial.print("Initializing Pulse Oximeter..");

  if (!pox.begin())
  {
    Serial.println("FAILED");
    oled.clearDisplay();
    oled.setTextSize(1);
    oled.setTextColor(1);
    oled.setCursor(0, 0);
    oled.println("FAILED");
    oled.display();
    for (;;);
  }
  else
  {
    oled.clearDisplay();
    oled.setTextSize(1);
    oled.setTextColor(1);
    oled.setCursor(0, 0);
    oled.println("SUCCESS");
    oled.display();
    Serial.println("SUCCESS");
    pox.setOnBeatDetectedCallback(onBeatDetected);
  }

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

}

void loop()
{
  pox.update();
  Blynk.run();

  BPM = pox.getHeartRate();
  SpO2 = pox.getSpO2();
      if (millis() - tsLastReport > REPORTING_PERIOD_MS)
  {
    Serial.print("Heart rate:");
    Serial.print(BPM);
    Serial.print(" SpO2:");
    Serial.print(SpO2);
    Serial.println(" %");

    Blynk.virtualWrite(V1, BPM);
    Blynk.virtualWrite(V2, SpO2);
    
    oled.clearDisplay();
    oled.setTextSize(1);
    oled.setTextColor(1);
    oled.setCursor(0, 16);
    oled.println(pox.getHeartRate());

    oled.setTextSize(1);
    oled.setTextColor(1);
    oled.setCursor(0, 0);
    oled.println("Heart BPM");

    oled.setTextSize(1);
    oled.setTextColor(1);
    oled.setCursor(0, 30);
    oled.println("Spo2");

    oled.setTextSize(1);
    oled.setTextColor(1);
    oled.setCursor(0, 45);
    oled.println(pox.getSpO2());
    oled.display();

    tsLastReport = millis();
  }
}

@Carvell please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code.
Triple backticks look like this:
```

Pete.

Okk, noted

What does your serial monitor show?

Pete.

Shown nothing here :sweat_smile:

Try closing then re-opening the serial monitor window, then pressing the reset button your board.

Pete.

I try several times but it stills shown nothing in serial monitor. Maybe the warning messages in command window can help to identify the problem?

WARNING: Category 'Network' in library lwIP_PPP is not valid. Setting to 'Uncategorized'
WARNING: Category 'Network' in library lwIP_enc28j60 is not valid. Setting to 'Uncategorized'
WARNING: Category 'Network' in library lwIP_w5500 is not valid. Setting to 'Uncategorized'
WARNING: Category 'Network' in library lwIP_w5500 is not valid. Setting to 'Uncategorized'
Archiving built core (caching) in: C:\Users\ASUS\AppData\Local\Temp\arduino_cache_619512\core\core_esp8266_esp8266_nodemcuv2_xtal_80,vt_flash,exception_disabled,stacksmash_disabled,ssl_all,mmu_3232,non32xfer_fast,eesz_4M2M,led_2,ip_lm2f,dbg_Disabled,lvl_None____,wipe_none,baud_115200_3cf7196efd3687923139732bd52fdeee.a

Executable segment sizes:


ICACHE : 32768           - flash instruction cache 


IROM   : 263996          - code in flash         (default or ICACHE_FLASH_ATTR) 


IRAM   : 28901   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...) 


DATA   : 1568  )         - initialized variables (global, static) in RAM/HEAP 


RODATA : 2628  ) / 81920 - constants             (global, static) in RAM/HEAP 


BSS    : 27552 )         - zeroed variables      (global, static) in RAM/HEAP

Did your original sketch (before you added Blynk) work?
If so, does it still work?

Pete.

Yes, the sensor can work before added Blynk :ok_hand:

And does it still work if you flash the old code?

Pete.

Yes it will also work after flash the old code

Does “it will” mean that you’ve just tried it and proven this?

Pete.

Yes, try before and it can work

That’s not what I’m asking.
If you re-flash your NodeMCU with the original sketch, does it still work now?

Your photos show that your project is built on a breadboard, with a messy collection of wires that may or may not still be working in the same way that it did when you tested it with your pre-Blynk code.

Your first troubleshooting step, when you’re getting no serial output, is to refer to your last “known good” configuration and prove beyond a doubt that this does still work, and produces the expected serial output.

Pete.

If you re-flash your NodeMCU with the original sketch, does it still work now?
If based on this statement my NodeMCU cannot work… the serial monitor remain nothing here :sweat_smile:

Hi Pete, I try another install another driver and run it. The serial monitor shows below

21:45:33.471 -> SDK:2.2.2-dev(38a443e)/Core:3.0.1=30001000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:c0b69df
21:45:34.495 -> [1072] Connecting to UniMAP-WiFi
21:45:34.495 -> fpm close 3 
21:45:34.495 -> mode : sta(e8:db:84:94:78:bf)
21:45:34.495 -> add if0
21:45:37.335 -> scandone
21:45:38.221 -> state: 0 -> 2 (b0)
21:45:38.221 -> state: 2 -> 3 (0)
21:45:38.267 -> state: 3 -> 5 (10)
21:45:38.267 -> add 0
21:45:38.267 -> aid 5
21:45:38.267 -> cnt 
21:45:48.242 -> pm open,type:2 0
21:46:59.630 -> state: 5 -> 2 (2a0)
21:46:59.630 -> rm 0
21:46:59.630 -> pm close 7
21:47:00.663 -> reconnect
21:47:00.663 -> state: 2 -> 0 (0)
21:47:00.753 -> scandone
21:47:00.753 -> state: 0 -> 2 (b0)
21:47:01.787 -> state: 2 -> 0 (2)
21:47:01.787 -> reconnect
21:47:01.880 -> scandone
21:47:01.880 -> state: 0 -> 2 (b0)
21:47:01.880 -> state: 2 -> 3 (0)
21:47:01.928 -> state: 3 -> 5 (10)
21:47:01.928 -> add 0
21:47:01.928 -> aid 5
21:47:01.928 -> cnt 
21:47:11.947 -> pm open,type:2 0
21:48:23.324 -> state: 5 -> 2 (2a0)
21:48:23.324 -> rm 0
21:48:23.324 -> pm close 7
21:48:24.346 -> reconnect
21:48:24.346 -> state: 2 -> 0 (0)
21:48:24.440 -> scandone
21:48:24.440 -> state: 0 -> 2 (b0)
21:48:24.440 -> state: 2 -> 3 (0)
21:48:25.465 -> state: 3 -> 0 (4)
21:48:25.465 -> reconnect
21:48:25.605 -> scandone
21:48:25.605 -> state: 0 -> 2 (b0)
21:48:25.605 -> state: 2 -> 3 (0)
21:48:25.651 -> state: 3 -> 5 (10)
21:48:25.651 -> add 0
21:48:25.651 -> aid 5
21:48:25.651 -> cnt 
21:48:35.629 -> pm open,type:2 0

So your device isn’t connecting to Blynk.
That’s what you need to focus on.

Pete.

Can hotspot be used? Because my wifi still cannot connect the blynk

22:22:25.422 -> no Carvell found, reconnect after 1s
22:22:25.515 -> reconnect

I don’t understand the question.

Pete.

Because I try both WiFi and mobile hotspot. I dont know what the problem and how should I solve it

22:34:05.935 -> state: 0 -> 2 (b0)
22:34:05.982 -> state: 2 -> 3 (0)
22:34:05.982 -> state: 3 -> 5 (10)
22:34:05.982 -> add 0
22:34:05.982 -> aid 7
22:34:05.982 -> cnt 
22:34:16.016 -> pm open,type:2 0

This is WiFi

22:22:25.422 -> no Carvell found, reconnect after 1s
22:22:25.515 -> reconnect

This is mobile hotspot