๐๐๐ ๐๐๐ฌ๐๐ ๐๐๐๐ซ๐ญ ๐๐๐ญ๐ ๐๐จ๐ง๐ข๐ญ๐จ๐ซ ๐ฎ๐ฌ๐ข๐ง๐ ๐๐ซ๐๐ฎ๐ข๐ง๐จ ๐๐ง๐ ๐๐๐๐๐๐๐
we are make a Heart Rate Monitoring System using Arduino, Pulse sensor, and ESP8266 WiFi module. The pulse sensor will detect the heart rate, and Arduino will send it to Thingspeak using the ESP8266 WiFi module
- ๐๐จ๐ฆ๐ฉ๐จ๐ง๐๐ง๐ญ๐ฌ ๐๐๐ช๐ฎ๐ข๐ซ๐๐ *
->๐๐ฎ๐ฅ๐ฌ๐ ๐ฌ๐๐ง๐ฌ๐จ๐ซ
->๐๐๐๐๐๐๐ ๐๐ข-๐ ๐ข ๐ฆ๐จ๐๐ฎ๐ฅ๐
->๐๐ซ๐๐ฎ๐ข๐ง๐จ ๐๐ง๐จ
->๐๐ซ๐๐๐ ๐๐จ๐๐ซ๐
->๐๐๐-๐จ๐ก๐ฆ ๐ซ๐๐ฌ๐ข๐ฌ๐ญ๐จ๐ซ๐ฌ
->๐๐๐
->๐๐จ๐ง๐ง๐๐๐ญ๐ข๐ง๐ ๐ฐ๐ข๐ซ๐๐ฌ
*๐๐ซ๐จ๐ ๐ซ๐๐ฆ๐ฆ๐ข๐ง๐ ๐๐จ๐๐ ๐๐ฑ๐ฉ๐ฅ๐๐ง๐๐ญ๐ข๐จ๐ง *
First of all, install all the required libraries and then enter your Wi-Fi name, password, and thingspeak.com api.
#include <SoftwareSerial.h> #include <stdlib.h> #define DEBUG true #define SSID "WiFi Name" // Enter Your WiFi Name Here #define PASS "WiFi Password" // Enter Your WiFi Password Here #define IP "api.thingspeak.com"// thingspeak.com api
Define the pins where you connected the esp8266 Tx and Rx and enter your Thingspeak API key.
SoftwareSerial ser(2,3); String msg = "GET /update?key=Your Api Key"; //Enter your API key
- ๐๐๐๐ข๐ง๐ ๐๐ฅ๐ฅ ๐ญ๐ก๐ ๐ข๐ง๐ญ๐๐ ๐๐ซ ๐๐ง๐ ๐ฏ๐จ๐ฅ๐๐ญ๐ข๐ฅ๐ ๐ฏ๐๐ซ๐ข๐๐๐ฅ๐๐ฌ ๐ญ๐ก๐๐ญ ๐ฐ๐ข๐ฅ๐ฅ ๐๐ ๐ฎ๐ฌ๐๐ ๐ญ๐จ ๐๐๐ฅ๐๐ฎ๐ฅ๐๐ญ๐ ๐ญ๐ก๐ ๐๐๐ (๐๐๐๐ญ๐ฌ ๐๐๐ซ ๐๐ข๐ง๐ฎ๐ญ๐). *
/Variables int error; int sensorPin = 0; // Connect Pulse Sensor Signal Pin to Analog Pin A0 int ledpin = 9; // Connect Led Positive Pin to Arduino Pin 9 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 volatile boolean Pulse = false; // "True" when heartbeat is detected. "False" when not a "live beat". volatile boolean QS = false; // becomes true when Arduino finds a beat.
-
๐๐ก๐ ๐ฏ๐จ๐ข๐ ๐ฎ๐ฉ๐๐๐ญ๐๐๐๐๐ญ() ๐๐ฎ๐ง๐๐ญ๐ข๐จ๐ง ๐ฐ๐ข๐ฅ๐ฅ ๐ฌ๐๐ง๐ ๐๐๐ญ๐ ๐ญ๐จ ๐ญ๐ก๐ ๐ฌ๐๐ซ๐ข๐๐ฅ ๐ฆ๐จ๐ง๐ข๐ญ๐จ๐ซ ๐๐ง๐ ๐๐ฅ๐ฌ๐จ ๐ฉ๐ฎ๐๐ฅ๐ข๐ฌ๐ก ๐ข๐ญ ๐ญ๐จ ๐ญ๐ก๐ ๐ญ๐ก๐ข๐ง๐ ๐ฌ๐ฉ๐๐๐ค ๐๐ก๐๐ง๐ง๐๐ฅ. *
void updatebeat() { String cmd = "AT+CIPSTART="TCP",""; cmd += IP; cmd += "",80"; Serial.println(cmd); ser.println(cmd); delay(2000); if(ser.find("Error")) { return; } cmd = msg ; cmd += "&field1=";
cmd += BPM; cmd += "\r\n"; Serial.print("AT+CIPSEND="); ser.print("AT+CIPSEND="); Serial.println(cmd.length()); ser.println(cmd.length()); if(ser.find(">")) { Serial.print(cmd); ser.print(cmd); } -
๐๐ก๐ ๐๐๐ฅ๐จ๐ฐ ๐๐จ๐๐ ๐ข๐ฌ ๐ฎ๐ฌ๐๐ ๐ญ๐จ ๐๐จ๐ง๐ฏ๐๐ซ๐ญ ๐ญ๐ก๐ ๐ฉ๐ฎ๐ฅ๐ฌ๐ ๐ฌ๐๐ง๐ฌ๐จ๐ซ ๐๐๐ญ๐ ๐ข๐ง๐ญ๐จ ๐๐๐ (๐๐๐๐ญ๐ฌ ๐๐๐ซ ๐๐ข๐ง๐ฎ๐ญ๐). *
ISR (TIMER2_COMPA_vect){ // triggered when Timer2 counts to 124 cli(); // disable interrupts while we do this Signal = analogRead(sensorPin); // read the Pulse Sensor sampleCounter += 2; // keep track of the time in mS int N = sampleCounter - lastBeatTime; // monitor the time since the last beat to avoid noise // find the peak and trough of the pulse wave
if(Signal < thresh && N > (IBI/5)*3){ // avoid dichrotic noise by waiting 3/5 of last IBI if (Signal < T){ // T is the trough T = Signal; // keep track of lowest point in pulse wave } } if(Signal > thresh && Signal > P){ // thresh condition helps avoid noise P = Signal; // P is the peak } // keep track of highest point in pulse wave if (N > 250){ // avoid high frequency noise if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){
Pulse = true; // set the Pulse flag when there is a pulse digitalWrite(ledpin,HIGH); // turn on pin 13 LED IBI = sampleCounter - lastBeatTime; // time between beats in mS lastBeatTime = sampleCounter; // keep track of time for next pulse if(secondBeat){ // if this is the second beat secondBeat = false; // clear secondBeat flag for(int i=0; i<=9; i++){ // seed the running total to get a realistic BPM at startup rate[i] = IBI;
} }
*๐๐ข๐ซ๐๐ฎ๐ข๐ญ ๐๐ข๐๐ ๐ซ๐๐ฆ