I am using MAX30102 sensor and Nodemcu ESP8266 in order to manage the data of the sensor by storing the IR and RED readings in an open array, which allows me to transmit it to FIREBASE in one go. The sample rate for the data is set to 50 samples per second. However, during operation, I observed that the sensor disconnects once the readings reach 300. I seek to understand if it is possible to extend the threshold beyond 500, and if so, how to achieve this. Additionally, I wonder if it is feasible to modify the sensor configuration to increase the sample rate, I tried this but the code will vary slow or also it will disconnect.
*** My code:
#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>
#include <Wire.h>
#include "MAX30105.h"
MAX30105 particleSensor;
#define timer 10000
#define debug Serial
#define FIREBASE_HOST ""
#define FIREBASE_AUTH ""
#define WIFI_SSID ""
#define WIFI_PASSWORD ""
FirebaseJsonArray arrIR;
FirebaseJsonArray arrRED;
FirebaseData IRdataobj;
FirebaseData Reddataobj;
float mill;
int i=0;
String key="/[";
String x="]";
void setup()
{
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500); }
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
debug.println("MAX30105 Basic Readings Example");
while(!Serial);
if (particleSensor.begin(Wire, I2C_SPEED_FAST) == false)
{
Serial.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
byte ledBrightness = 255; //Options: 0=Off to 255=50mA
byte sampleAverage = 1; //Options: 1, 2, 4, 8, 16, 32
byte ledMode = 2; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
int sampleRate = 100; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
int pulseWidth = 69; //Options: 69, 118, 215, 411
int adcRange = 16384; //Options: 2048, 4096, 8192, 16384
particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings
}
void loop()
{
for (int a=0;a<500;a++){
key.concat(i);
key.concat(x);
Serial.println("key index"+key);
arrIR.set(key,particleSensor.getIR());
arrRED.set(key,particleSensor.getRed());
key="/[";
i++;
if (millis() - mill > timer) {
mill=millis();
key="/[";
}
}
Firebase.set(IRdataobj,"IR",arrIR);
Firebase.set(Reddataobj,"RED",arrRED);
arrIR.clear();
arrRED.clear();
i=0; }