Our Minor Projeccts Components and Code
Our Minor Projeccts Components and Code
The Pulse Sensor is a plug-and-play heart-rate sensor for Arduino. It can be used by students, artists,
athletes, makers, and game & mobile developers who want to easily incorporate live heart-rate data into their
projects. The essence is an integrated optical amplifying circuit and noise eliminating circuit sensor. Clip
the Pulse Sensor to your earlobe or fingertip and plug it into your Arduino, you can ready to read heart rate.
The pulse sensor has three pins: VCC, GND & Analog Pin.
There is also a LED in the center of this sensor module which helps in detecting the heartbeat. Below the LED, there is a
noise elimination circuitry that is supposed to keep away the noise from affecting the readings.
Centigrade temperature. The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the
user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling. The
LM35 device does not require any external calibration or trimming to provide typical accuracies of ±¼°C at room
both as an Access point (can create hotspot) and as a station (can connect to Wi-Fi), hence it can easily fetch data and upload it
to the internet making the Internet of Things as easy as possible. It can also fetch data from the internet using API’s hence your
project could access any information that is available on the internet, thus making it smarter. Another exciting feature of this
module is that it can be programmed using the Arduino IDE which makes it a lot more user-friendly.
The ESP8266 module works with 3.3V only, anything more than 3.7V would kill the module hence be
g the Channels and web pages provided by ThingSpeak. So first you need to sign up for ThingSpeak. So
clarification.Then create the API keys. This key is required for programming modifications and setting your data.
Then upload the code to the Arduino UNO by assembling the circuit shown above. Open the serial monitor and it will
Now click on channels so that you can see the online data streaming, i.e IoT Based Patient Health Monitoring System
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
float pulse = 0;
float temp = 0;
SoftwareSerial ser(9,10);
// Variables
int pulsePin = A0; // Pulse Sensor purple wire connected to analog pin 0
int fadePin = 13; // pin to do fancy classy fading blink at each beat
volatile int BPM; // int that holds raw Analog in 0. updated every 2mS
volatile int Signal; // holds the incoming raw data
volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!
volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when nota "live beat".
static boolean serialVisual = true; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII
Visual Pulse
volatile int thresh = 525; // used to find instant moment of heart beat, seeded
volatile int amp = 100; // used to hold amplitude of pulse waveform, seeded
volatile boolean firstBeat = true; // used to seed rate array so we startup with reasonable BPM
volatile boolean secondBeat = false; // used to seed rate array so we startup with reasonable BPM
void setup()
lcd.begin(16, 2);
// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,
// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN
// analogReference(EXTERNAL);
lcd.clear();
lcd.setCursor(0,0);
lcd.setCursor(0,1);
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Initializing....");
delay(5000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Getting Data....");
ser.begin(9600);
ser.println("AT");
delay(1000);
ser.println("AT+GMR");
delay(1000);
ser.println("AT+CWMODE=3");
delay(1000);
ser.println("AT+RST");
delay(5000);
ser.println("AT+CIPMUX=1");
delay(1000);
String cmd="AT+CWJAP=\"Alexahome\",\"98765432\"";
ser.println(cmd);
delay(1000);
ser.println("AT+CIFSR");
delay(1000);
void loop()
serialOutput();
fadeRate = 255; // Makes the LED Fade Effect Happen, Set 'fadeRate' Variable to 255 to fade LED with pulse
read_temp();
esp_8266();
void ledFadeToBeat()
void interruptSetup()
TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE
OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE
void serialOutput()
if (serialVisual == true)
else
void serialOutputWhenBeatHappens()
Serial.println(BPM);
else
// range value:
switch (range)
case 0:
break;
case 1:
Serial.println("---");
break;
case 2:
Serial.println("------");
break;
case 3:
Serial.println("---------");
break;
case 4:
Serial.println("------------");
break;
case 5:
Serial.println("--------------|-");
break;
case 6:
Serial.println("--------------|---");
break;
case 7:
Serial.println("--------------|-------");
break;
case 8:
Serial.println("--------------|----------");
break;
case 9:
Serial.println("--------------|----------------");
break;
case 10:
Serial.println("--------------|-------------------");
break;
case 11:
Serial.println("--------------|-----------------------");
break;
}
}
Serial.print(symbol);
Serial.println(data);
int N = sampleCounter - lastBeatTime; // monitor the time since the last beat to avoid noise
if(Signal < thresh && N > (IBI/5)*3) // avoid dichrotic noise by waiting 3/5 of last IBI
Pulse = true; // set the Pulse flag when we think there is a pulse
if(secondBeat)
for(int i=0; i<=9; i++) // seed the running total to get a realisitic BPM at startup
rate[i] = IBI;
BPM = 60000/runningTotal; // how many beats can fit into a minute? that's BPM!
pulse = BPM;
T = thresh;
if (N > 2500)
void esp_8266()
cmd += "\",80";
ser.println(cmd);
Serial.println(cmd);
if(ser.find("Error"))
Serial.println("AT+CIPSTART error");
return;
getStr += apiKey;
getStr +="&field1=";
getStr +=String(temp);
getStr +="&field2=";
getStr +=String(pulse);
getStr += "\r\n\r\n";
cmd = "AT+CIPSEND=4,";
cmd += String(getStr.length());
ser.println(cmd);
Serial.println(cmd);
delay(1000);
ser.print(getStr);
delay(3000);
void read_temp()
//float mv = (temp_val/1024.0)*5000;
Serial.print("Temperature:");
Serial.println(temp);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("BPM :");
lcd.setCursor(7,0);
lcd.print(BPM);
lcd.setCursor(0,1);
lcd.print("Temp.:");
lcd.setCursor(7,1);
lcd.print(temp);
//lcd.setCursor(13,1);
lcd.print("F");