Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include thingProperties.h #include DHT . h #include #include MAX 3 0 1 0 5 . h #include #include heartRate.h #define

#include "thingProperties.h"
#include "DHT.h"
#include
#include "MAX30105.h"
#include
#include "heartRate.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);
MAX30105 particleSensor;
const byte RATE_SIZE =4; //Increase this for more averaging. 4 is good.
byte rates[RATE_SIZE]; //Array of heart rates
byte rateSpot =0;
long lastBeat =0; //Time at which the last beat occurred
float beatsPerMinute;
int beatAvg;
float f =0.0; // Initialize 'f' with a value
float h =0.0; // Initialize 'h' with a value
float t =0.0;
//TFT_eSPI myGLCD;
TFT_eSPI myGLCD = TFT_eSPI();
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);
}
Serial.println("Place your index finger on the sensor with steady pressure.");
particleSensor.setup(); //Configure sensor with default settings
particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running
particleSensor.setPulseAmplitudeGreen(0);
//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 vvvvvvvvvvvvvvvvvv vvvvvv; //Options: 69,118,215,411
//int adcRange =4096; //Options: 2048,4096,8192,16384
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 ;
long irValue = particleSensor.getIR();
if (checkForBeat(irValue)== true)
{
//We sensed a beat!
long delta = millis() this is my code using max30102. but i cant getcorrect bpm. can you identify problem. code only

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Explain and criticize the JamesLange theory of emotion.

Answered: 1 week ago