Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include thingProperties.h #include DHT . h #define DHTPIN 2 6 / / Digital pin connected to the DHT sensor / / Feather
#include "thingProperties.h
#include DHTh
#define DHTPIN Digital pin connected to the DHT sensor
Feather HUZZAH ESP note: use pins or
Pin can work but DHT must be disconnected during program upload.
Uncomment whatever type you're using!
#define DHTTYPE DHT DHT
#define DHTTYPE DHT DHT AM AM
#define DHTTYPE DHT DHT AM
DHT dhtDHTPIN DHTTYPE;
#include
#include "MAXh
#include
MAX particleSensor;
TFTeSPI myGLCD;
void setup
Initialize serial and wait for port to open:
Serial.begin;
Serial.printlnFDHTxx test!";
dhtbegin;
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.beginArduinoIoTPreferredConnection;
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 only errors
Maximum is
setDebugMessageLevel;
ArduinoCloud.printDebugInfo;
Serial.printlnInitializing;
Initialize sensor
if particleSensor.beginWire ICSPEEDFASTUse default IC port, kHz speed
Serial.printlnMAX was not found. Please check wiringpower;
while ;
Setup to sense a nice looking saw tooth on the plotter
byte ledBrightness xF; Options: Off to mA
byte sampleAverage ; Options:
byte ledMode ; Options: Red only, Red IR Red IR Green
int sampleRate ; Options:
int pulseWidth ; Options:
int adcRange ; Options:
particleSensor.setupledBrightness sampleAverage, ledMode, sampleRate, pulseWidth, adcRange; Configure sensor with these settings
Arduino plotter autoscales annoyingly. To get around this, prepopulate
the plotter with of an average reading from the sensor
Take an average of IR readings at power up
const byte avgAmount ;
long baseValue ;
for byte x ; x avgAmount ; x
baseValue particleSensor.getIR; Read the IR value
baseValue avgAmount;
Prepopulate the plotter so that the Y scale is close to IR values
for int x ; x ; x
Serial.printlnbaseValue;
particleSensor.setupxF;
myGLCDinit;
myGLCDsetRotation;
myGLCDfillScreenTFTBLACK;
void loop
ArduinoCloud.update;
Your code here
Wait a few seconds between measurements.
delay;
Reading temperature or humidity takes about milliseconds!
Sensor readings may also be up to seconds 'old' its a very slow sensor
float h dhtreadHumidity;
Read temperature as Celsius the default
float t dhtreadTemperature;
Read temperature as Fahrenheit isFahrenheit true
float f dhtreadTemperaturetrue;
Check if any reads failed and exit early to try again
if isnanh isnant isnanf
Serial.printlnFFailed to read from DHT sensor;
return;
temperaturet ;
humidityh ;
heartrateparticleSensor.getIR;
Compute heat index in Fahrenheit the default
float hif dhtcomputeHeatIndexf h;
Compute heat index in Celsius isFahreheit false
float hic dhtcomputeHeatIndext h false;
Serial.printFHumidity: ;
Serial.printh;
Serial.printF Temperature: ;
Serial.printt;
Serial.printFdeg C ;
Serial.printf;
Serial.printFdeg F Heat index: ;
Serial.printhic;
Serial.printFdeg C ;
Serial.printhif;
Serial.printlnFdeg F;
Serial.printlnparticleSensorgetIR; Send raw data to plotter
Serial.printlnheartrate;
myGLCDfillScreenTFTBLACK;
myGLCDsetTextColorTFTWHITE;
myGLCDsetTextSize;
myGLCDsetCursor;
myGLCDprintTemperature: ;
myGLCDprinttemperature;
myGLCDprintlnC;
myGLCDsetCursor;
myGLCDprintHumidity: ;
myGLCDprinthumidity;
myGLCDprintln;
myGLCDsetCursor;
myGLCDprintHeart Rate: ;
myGLCDprintheartrate;
myGLCDprintln bpm;
delay;
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started