Ardunio uno + max30100+ esp-01

hi im using arduino uno and max30100 sensor with esp-01 wifi module. ok so when i connect max30100 and esp-01 individually they seem to work fine but when i just connect them together neither it connects to my wifi nor the max30100 intializes i think. my professor said the issue might be with timers cause sensor and wifi module both are trynna use it. can someone guide me through it

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
#include <SimpleTimer.h>
#define ESP8266_BAUD 9600
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"

char auth[] = "Uz6xxCZdK2X11-3AFGKY14AOHiujdmGe";
char ssid[] = "EsparkTech"; //You can replace the wifi name to your wifi

char pass[] = "IOT1234765";  //Type password of your wifi.

SoftwareSerial EspSerial(10, 11); // RX, TX
PulseOximeter pox;
ESP8266 wifi(&EspSerial);
SimpleTimer timer;
#define REPORTING_PERIOD_MS 1000
float BPM, SpO2;
uint32_t tsLastReport = 0;
void setup()
{

  Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
  Blynk.begin(auth, wifi, ssid, pass);
   
}

void loop()
{pox.update();
  Blynk.run();
  BLYNK_CONNECTED();
  timer.run();
  
    BPM = pox.getHeartRate();
    SpO2 = pox.getSpO2();
     if (millis() - tsLastReport > REPORTING_PERIOD_MS)
    {
        Serial.print("Heart rate:");
        Serial.print(BPM);
        Serial.print(" bpm / SpO2:");
        Serial.print(SpO2);
        Serial.println(" %");
 
        Blynk.virtualWrite(V5, BPM);
        Blynk.virtualWrite(V6, SpO2);
        
        
 
        tsLastReport = millis();
    }
  
}

Hey there, you should read this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

also try this

SoftwareSerial EspSerial(2, 3); // RX, TX

I have read that and i tried the following code as they instructed but still getting the same issue. Now theres this warning as well

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#define ESP8266_BAUD 9600
#define REPORTING_PERIOD_MS     1000
char auth[] = "Uz6xxCZdK2X11-3AFGKY14AOHiujdmGe";
char ssid[] = "EsparkTech";
char pass[] = "IOT1234765";
SoftwareSerial EspSerial(10, 11); // RX, TX
ESP8266 wifi(&EspSerial);
SimpleTimer timer; 
PulseOximeter pox;
uint32_t tsLastReport = 0; 
void onBeatDetected()
{
    Serial.println("Beat!");
}

void sendSensor()
{
  float h = pox.getHeartRate();
  float t = pox.getSpO2();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from max sensor!");
    return;
  }
  
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}
 
void setup()
{
    Serial.begin(9600);
     EspSerial.begin(ESP8266_BAUD);
  Blynk.begin(auth, wifi, ssid, pass);
    Serial.print("Initializing pulse oximeter..");
    delay(3000);
    if (!pox.begin()) {
        Serial.println("FAILED");
        for(;;);
    } else {
        Serial.println("SUCCESS");
    }
     pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
    
    //pox.setOnBeatDetectedCallback(onBeatDetected);
    timer.setInterval(1000L, sendSensor);
}
 
void loop()
{
    
    Blynk.run();
  timer.run();
    pox.update();
    
    
}

Your void loop should look like this

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

And you didn’t change the TX RX pins.

Quick update. max sensor seems to initialize but my esp-01 is having trouble connecting to wifi taking alot of time before giving me this error. and yes next try ill change RX TX pins.

EDIT- why do you reckon esp-01 wont connect is it because of the timmer issues?

I’d start by using a simple example sketch from the Sketch Builder or Blynk library examples.

Based on your previous post, I’m guessing that you haven’t configured your ESP-01 correctly to work at a baud rate of 9600.
You may also have the Arduino and ESP-01 connected incorrectly, and you might not be powering the ESP-01 correctly.

Also, your SSID of “EsparkTech” seems to be one that you’ve created for this project, as oppose to a regular domestic WiFi SSID.
Is this a mobile hotspot that you’ve created on your phone?

On a slightly broader subject, you will probably struggle to get the pulse oximeter to work correctly with Blynk, as Blynk has specific timing requirements, and so does hardware like the pulse oximeter. Blynk needs a clean void loop and non-blocking timers, and devices like the pulse oximeter require constant monitoring to give accurate results.
Your choice of hardware is also very poor. The Uno is under powered and short on memory (as you’ve discovered with your latest compiler message) and has no built-in internet connectivity.
The Mega has more memory, and more hardware serial ports, but is still an extremely poor choice.
For a project like this one, I’d say that the only realistic choice of processor is to use an ESPP32, as this has two cores and you could run the Blynk code on one and the pulse oximeter code in the other - provided your coding skills are good enough to write multi-threaded code.

Pete.

1 Like

No No I did manage to change the baud rate to 9600 through AT commands. The wifi is actually a router.
I know all the issues with memory and timers and that it requires constant monitoring, the issue is the place that I intern at they create projects for Bachelor students so their requirement is arduino uno only, mate if it was upto me i wouldve happily changed my hardware to nodemcu cause theres literally readymade code for that. But my boss wants me to get it done on uno and uno only.

EDIT- is there any way that it could be done on uno? ive been trying every possible scenarios for a day now nothing seems to be working.

Have you tried this example

You seem to have ignored most of what I said in my last post, and focussed on why you need to stick with the Uno + ESP-01

In this forum you have access to people with lots of knowledge about how to get the Uno + ESP-01 working with Blynk. You aren’t making the most of that experience by providing any detail about what you’ve done so far to get this hardware working with a basic sketch.
As far as the pulse oximeter hardware is concerned, you seem to believe that you…

so you’ll be aware of the challenges that you face getting this working alongside Blynk.

Pete.