Question: #include thingProperties.h #include DHT . h #define DHTPIN 2 6 / / Digital pin connected to the DHT sensor / / Feather

#include "thingProperties.h"
#include "DHT.h"
#define DHTPIN 26// Digital pin connected to the DHT sensor
// Feather HUZZAH ESP8266 note: use pins 3,4,5,12,13 or 14--
// Pin 15 can work but DHT must be disconnected during program upload.
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11// DHT 11
#define DHTTYPE DHT11// DHT 22(AM2302), AM2321
//#define DHTTYPE DHT21// DHT 21(AM2301)
DHT dht(DHTPIN, DHTTYPE);
#include
#include "MAX30105.h"
#include
MAX30105 particleSensor;
TFT_eSPI myGLCD;
void setup(){
// Initialize serial and wait for port to open:
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information youll get.
The default is 0(only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
Serial.println("Initializing...");
// Initialize sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST))//Use default I2C port, 400kHz speed
{
Serial.println("MAX30105 was not found. Please check wiring/power.");
while (1);
}
//Setup to sense a nice looking saw tooth on the plotter
byte ledBrightness =0x1F; //Options: 0=Off to 255=50mA
byte sampleAverage =8; //Options: 1,2,4,8,16,32
byte ledMode =3; //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 =411; //Options: 69,118,215,411
int adcRange =4096; //Options: 2048,4096,8192,16384
particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings
//Arduino plotter auto-scales annoyingly. To get around this, pre-populate
//the plotter with 500 of an average reading from the sensor
//Take an average of IR readings at power up
const byte avgAmount =64;
long baseValue =0;
for (byte x =0 ; x < avgAmount ; x++)
{
baseValue += particleSensor.getIR(); //Read the IR value
}
baseValue /= avgAmount;
//Pre-populate the plotter so that the Y scale is close to IR values
for (int x =0 ; x <500 ; x++)
Serial.println(baseValue);
particleSensor.setup(0x1F,8,3,100,411,4096);
myGLCD.init();
myGLCD.setRotation(1);
myGLCD.fillScreen(TFT_BLACK);
}
void loop(){
ArduinoCloud.update();
// Your code here
// Wait a few seconds between measurements.
//delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h)|| isnan(t)|| isnan(f)){
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
temperature=t ;
humidity=h ;
heartrate=particleSensor.getIR();
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("\deg C "));
Serial.print(f);
Serial.print(F("\deg F Heat index: "));
Serial.print(hic);
Serial.print(F("\deg C "));
Serial.print(hif);
Serial.println(F("\deg F"));
Serial.println(particleSensor.getIR()); //Send raw data to plotter
Serial.println(heartrate);
myGLCD.fillScreen(TFT_BLACK);
myGLCD.setTextColor(TFT_WHITE);
myGLCD.setTextSize(2);
myGLCD.setCursor(10,10);
myGLCD.print("Temperature: ");
myGLCD.print(temperature);
myGLCD.println("C");
myGLCD.setCursor(10,40);
myGLCD.print("Humidity: ");
myGLCD.print(humidity);
myGLCD.println("%");
myGLCD.setCursor(10,70);
myGLCD.print("Heart Rate: ");
myGLCD.print(heartrate);
myGLCD.println(" bpm");
delay(2000);
}
void onTemperatureChange(){
}
void onHumidityChange(){
// Add your code here to act upon Humidity change
} thisis my code for heart rate , but i am getting IR values, i need bpm , can you rectify the code for me

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!