IOT Patient
IOT Patient
STUDENT’S NAME
Atheer Hani Muhammad
Muhammad Haider Nasser
Abbas Yahya Hamoud
Supervised by
Assist. Lec: Sajjad Hadi Hussein
2023-2024
Najaf, Iraq
SUPERVISOR CERTIFICATE
I hereby certify that this project report is based on my original work except for citations and
quotations which have been duly acknowledged.
Signature :
Date : 2024 / /
I
EXAMINING COMMITTEE CERTIFICATE
We certify that this project report entitle “Heart Rate Monitoring and Pulse Oximeter
System” was prepared by Assist. Lec: Sajjad Hadi Hussein has met the required standard
for submission in partial fulfilment of the requirements for the award of Bachelor of
Computer Techniques Engineering at College of Technical Engineering / University of
AlKafeel.
Approved by,
Signature : Signature :
Member : Member :
Signature :
Chairman :
Date : 2024 / /
Signature :
Head of Dept. :
Date : 2024 / /
II
ACKNOWLEDGEMENTS
I would like to extend my heartiest gratitude to Assist. Lec: Sajjad Hadi
Hussein my project supervisor, for his invaluable guidance, inspirations and
timely suggestions which facilitated the entire process of bringing out this
project on " Heart Rate Monitoring and Pulse Oximeter System". It would have
been really hard to complete this project successfully without the directions of
whom. I really couldn’t have done it without him.
I also extend my love and respect to the Head of the Department of computer
technical Engineering, and to all professors who were most fortunate to extend
a helping hand during my studies.
III
ABSTRACT
The Internet of things has provided opportunity and applications for medical
patients. The IOT applications are key enabling technologies in medical
service. It is important way for taking care of patient’s health. IOT is consisting
of communication and sensors which are suitable tools for IOT based health
care monitoring system. This project introduces an IoT-Based Patient Health
Monitoring System designed for hospital beds, employing a synergy of
hardware components, including Arduino Nano, ESP8266 WIFI module, heart
rate sensor, IR temperature sensor, DHT11 sensor, and a 4x20 LCD display.
The system is configured to seamlessly integrate with the Thingspeak cloud
platform, establishing a robust communication network for real-time data
transmission and analysis. The aim of this review project is to summarize
various health parameters of human body such as temperature body, blood
oxygen and heart rate using sensors. Deploying this IoT-based monitoring
system on hospital beds represents a paradigm shift in healthcare delivery,
emphasizing proactive and data-driven approaches. The proposed system not
only addresses the limitations of traditional monitoring methods but also lays
the foundation for a more efficient and patient-centric healthcare ecosystem.
This project contributes to the evolving landscape of IoT applications in
healthcare and sets the stage for further advancements in remote patient
monitoring and care.
IV
TABLE OF CONTENTS
Titles Page NO
ACKNOWLEDGEMENTS III
ABSTRACT IV
TABLE OF CONTENTS V
CHAPTER ONE 1
GENERAL INTRODUCTION 1
1.1 INTRODUCTION 1
1.2 MOTIVATION 2
1.4 Objectives 3
CHAPTER TWO 5
LITERATURE REVIEW 5
CHAPTER THREE 9
V
3.1 Introduction 9
3.4.1 ThingSpeak 15
CHAPTER FOUR 17
CHAPTER FIVE 20
5.1 Conclusion 20
REFERENCES 21
APPENDIX A 23
VI
LIST OF FIGURE
Fig 3-1: A block Diagram of the proposed system...........................................10
Fig 3-2: Arduino Nano....................................................................................11
Fig 3-3: Wi-Fi Module ESP8266.....................................................................12
Fig 3-4: DHT11 Sensor Module......................................................................13
Fig 3-5: Heart rate sensor module MAX30102 - pulse sensor........................13
Fig 3-6: MLX90614 Infrared Non-contact Temperature Sensor Module........14
Fig 3-7: LCD 20*4 Display............................................................................15
Fig 3-8: ThingSpeak website..........................................................................16
Fig 4-1: Interfacing of LCD and sensors with Arduino...................................17
Fig 4-2: Result displayed on 4x20 LCD..........................................................18
Fig 4-3: Graphs of sensor output on the thing speak.......................................18
Fig 4-4: Finally shape of project.....................................................................19
VII
LIST OF ABBREVIATIONS
AHA American Heart Association
ECG Electrocardiogram
GPIO General Purpose Input/Output
I2C Inter-Integrated Circuit
IDE Integrated Development Environment
IOT Internet of Things
IR Infrared
LCD Liquid Crystal Display
LED Light Emitting Diode
NTC Negative Temperature Coefficient
PWM Pulse Width Modulation
RF Radio Frequency
SOC System on a Chip
USB Universal Serial Bus
WSN Wireless Sensor Network
VIII
CHAPTER ONE
GENERAL INTRODUCTION
1.1 INTRODUCTION
In today’s world it is very difficult to carry patients from home to hospitals
for regular checkup. There are lot of challenges like waiting in the queue,
travelling time and patient may be prone to various infections moving in this
polluted environment. So, the health care industry is focusing on in-home health
care services where the patient can undergo medical check-ups in the comfort of
his home environment. Health care industry is working together with Information
and communication technology industry to develop models that reduces the time
consumption, increasing accuracy and interoperable on any platform that can be
beneficial to both hospitals and patient [1]. Nowadays Internet of Things (IOT) is
attaining development on a rapid pace and experts estimate that about 50 billion
devices will be connected to the internet by 2020. It is a technology in which all
the devices like vehicles, buildings, sensors etc. are connected to the internet
through the existing infrastructure. Biotelemetry is the electrical technique for
conveying biological information from a living organism and its environment to
location where the information can be observed or recorded. A wireless health
monitoring device will be attached to the patient and physicians can monitor the
patient from anywhere across the world [2]. Typically, the patient health
monitoring system consists of various sensors that measure the physiological
information from the patient and transfer them to an Arduino as electrical signals.
The microcontroller processes this physiological data and transmits them to
associated ThingSpeak website that is linked to the IoT module. The doctor or the
caretaker can access the website by typing the unique id given to the patient. As
we are storing the data in the cloud it can be accessed anywhere, anytime over the
1
internet. The patient need not carry all the medical reports for the check-up. The
doctor can directly access the medical reports by typing the patient’s id on that
website.
1.2 MOTIVATION
In the realm of healthcare, where each advancement holds the potential to
transform lives, the integration of Internet of Things (IoT) technology into patient
health monitoring systems stands as a beacon of hope and progress. As we embark
on the journey of exploring and implementing an IoT-based Patient Health
Monitoring System, envision a future where the bed of sickness becomes a
platform for empowerment and healing. This project endeavor not only transcends
the traditional boundaries of healthcare but also symbolizes a paradigm shift in
how we perceive patient care. Picture a hospital where every bed is not just a place
of rest for the ailing, but a node within a dynamic network, constantly relaying
vital health data to caregivers in real-time. This IoT-driven metamorphosis
promises not only increased efficiency in monitoring patients but also a more
compassionate and personalized approach to healthcare. Let the prospect of this
transformative system propel us forward in our research, as we strive to bring
about positive change and redefine the landscape of patient well-being. In the
convergence of technology and compassion lies the motivation to create a future
where the hospital bed becomes a symbol of not just recovery, but of resilience
and innovation.
2
bed. The integration of Arduino Nano, heart rate sensor, IR sensor, DHT11 sensor,
and LCD into a cohesive IoT-based Patient Health Monitoring System represents
a promising avenue for addressing these challenges. However, the current
problem lies in the absence of a well-established and optimized framework that
fully exploits the capabilities of these components. Furthermore, issues related to
data security, sensor accuracy, and the integration of this system with existing
hospital infrastructure need to be meticulously addressed. This research seeks to
bridge these gaps by developing a robust and scalable IoT-based patient health
monitoring system that leverages Arduino Nano and a suite of sensors, ensuring
real-time data acquisition, analysis, and presentation. Through this investigation,
we aim to overcome the current limitations and pave the way for a more efficient,
reliable, and patient-centric healthcare monitoring paradigm.
1.4 Objectives
There are several objectives to achieve in this project. The objectives are:
• To ensure a stable foundation for real-time data collection and transmission
from patient health monitoring devices placed on hospital beds.
• To design a sensor integration system that is accurate, non-intrusive, and
adaptable to various patient conditions.
• To create a system which uses the cloud to store patient data.
3
1.5 Organization of the project
Chapter Two: delves into an extensive review of existing literature related
to IoT applications in healthcare and patient monitoring systems. It analyses prior
research findings, methodologies, and technological frameworks.
Chapter Three: focuses on the detailed design and architecture of the
proposed Patient Health Monitoring System. We outline the integration of
Arduino Nano, heart rate sensor, IR sensor, DHT11 sensor, and LCD display
within a cohesive framework.
Chapter Four: details the practical implementation of the IoT-based
monitoring system. It covers the step-by-step process of assembling the hardware
components, coding the software logic, and ensuring seamless integration.
Chapter Five: concludes with a summary of the project's achievements,
contributions to existing knowledge, and recommendations for future
enhancements.
4
CHAPTER TWO
LITERATURE REVIEW
5
storing, and distributing patient’s data. In [5], author presented a “Review on-IOT
Based smart healthcare system”. Here architecture of Smart Health Care
Monitoring and IOT is demonstrated by author. New technologies help in
minimizing the better quality as well security concept. ECG signals are obtained
by electrodes that are placed on the chest. Later wires are connected to ECG
sensor (AD8232). The sensor is used in measuring the electrical activity of the
heart. Problems and challenges that could be faced in future are presented by this
system. Applications of IOT can be improved using new methodologies and
technologies. Sensors like Blood pressure, Temperature, Heart rate, ECG are used
in IOT along with Raspberry Pi kit and Wi-Fi module. In [6], author has presented
“An Overview on Heart rate Monitoring and Pulse Oximeter System”. In this
paper a low-cost device is described that measures the heart rate of the patient by
placing sensors on the fingers, later the result will be displayed on LCD. The
designed system can be used by unprofessional people. The change in heart rate
can be displayed by graph using graphical LCD. Over a period of time, maximum
and minimum heart rate can be displayed using the designed system.
Abnormalities are displayed on LCD indicated by buzzer. In order to send heart
rate to PC output should be attached. In [7], author has presented “Heart rate
Measurement from the Finger Using a Low-Cost Microcontroller”. IOT has a
wide range of application. IoT has been developed for Wireless sensor network
(WSN). Using IOT, health monitoring designs are presented. There are some
problems that are related to health monitoring and IOT. New technologies help to
minimize better quality as well as security concept. New technologies and
methodologies are used. Aurdino board, Wi-Fi modules, temperature, pulse
oximeter, blood pressure, heartbeat rate sensors are used in IoT.
6
pressure. Patients who need a regular monitoring by doctors to discuss the state
of health condition, IoT based patient monitoring system is useful for them. The
main concept of IoT is defined as the integration with electronic devices that
connect with doctors or health monitoring persons. IoT the term was first
mentioned by Kevin Ashtor in 1998. IoT can be divided in three sections.
1. Internet – Oriented Middle ware.
2. Things Sensors Oriented.
3. Knowledge Oriented Semantics.
First as hardware layer which allow the interconnection by using sensors and
technologies. Sensors are used to measure Heartbeat, and Temperature etc. The
main purpose of this IoT is to improve a solution based on ontology with ability
to monitor the health status [8].
7
resting mode, it is the best time to measure heartbeat. According (AHA) for adults
and older normal heart rate is between 60 and 100 beats per minute (bpm). But
below 60 (bpm) doesn’t mean the person has health issue problem. Active people
have lower heart rates because their muscles don’t need to work as hard to
maintain a steady beat. Maximum and target heart rate: A person’s target heart
rate zone is between 50 percent and 85 percent of his or her maximum heart rate.
According to (AHA) 30-year-old person would be between 50 and 85 percent of
his or her max heart rate [9].
8
CHAPTER THREE
3.1 Introduction
This chapter provides a comprehensive overview of the software design and
implementation of the IoT-based environmental monitoring system. The chapter
includes a description of the system architecture, a discussion of the software
components, and the block diagram, circuit diagram, and flowchart of the system.
The system consists of the following components:
• Sensors: Heart rate sensor, IR temperature sensor and DHT11sensor.
• Microcontroller: The Arduino Nano microcontroller is used to collect data
from the sensors and process it.
• WiFi Module: The ESP8266 WiFi module is used to connect the
microcontroller to the internet.
• Cloud Platform: The ThinkSpeak cloud platform is used to store and
visualize data.
ThingSpeak
11
out of the box)! The ESP-01S ESP8266 module is an extremely cost-effective
board with a huge, and ever growing, community.
This module has a powerful enough on-board processing and storage capability
that allows it to be integrated with the sensors and other application specific
devices through its General-purpose input/output (GPIOs) with minimal
development up-front and minimal loading during runtime. Its high degree of on-
chip integration allows for minimal external circuitry, including the front-end
module, is designed to occupy minimal PCB area. The ESP8266 supports APSD
for VoIP applications and Bluetooth co-existance interfaces, it contains a self-
calibrated RF allowing it to work under all operating conditions and requires no
external RF parts [13].
12
Fig 3-4: DHT11 Sensor Module.
13
3.3.5 MLX90614 Infrared Temperature Sensor Module
The MLX90614 is an Infra-Red thermometer for non-contact temperature
measurements. Both the IR sensitive thermopile detector chip and the signal
conditioning ASIC are integrated in the same TO-39 can. Integrated into the
MLX90614 are a low noise amplifier, 17-bit ADC and powerful DSP unit thus
achieving high accuracy and resolution of the thermometer. The thermometer
comes factory calibrated with a digital SMBus output giving full access to the
measured temperature in the complete temperature range(s) with a resolution of
0.02°C. The user can configure the digital output to be PWM. As a standard, the
10-bit PWM is configured to continuously transmit the measured temperature in
range of -20 to 120 °C, with an output resolution of 0.14 °C. Works from 3.3V to
5V input, Module has power regulator IC built in. Standard I2C interface with
built 2x pull up resistors Operating Voltage: 3V- 5V [16]. Figure (3.6) represent
MLX90614 Infrared Non-contact Temperature Sensor Module.
14
Features
• High contrast STN 20x4 character LCD
• White text on blue background
• Single +5.0V supply operation
• LED backlight 27 o 5x8 dot characters
• HD44780 equivalent controller
3.4.1 ThingSpeak
The Thing Speak server is a data platform that is available to the public. API
for the Internet of Things that allows you to interact with it. data collection,
storage, analysis, visualization, and action derived from sensors. ThingSpeak
provides a very good tool for IoT based projects. By using the ThingSpeak site,
we can monitor our data and control our system over the Internet, using the
Channels and web pages provided by ThingSpeak. So first you need to sign up
for ThingSpeak. So visit https://thingspeak.com and create an account.You may
collect, visualize, and analyses real-time data streams with the cloud based IoT
analytics platform ThingSpeak [18]. Data transmitted to ThingSpeak by your
devices is visualized in real time by ThingSpeak. You have the option to run
MATLAB® code in ThingSpeak to perform online analysis and analyse data as
15
it is received. For the creation of IoT systems and proof-of-concept analytics,
ThingSpeak is commonly utilized. You can send data straight to ThingSpeak from
any internet-connected device via a Rest API or MQTT. The Things Network,
Senet, the Libelium Meshlium gateway, and Particle.io cloud-to-cloud
integrations allow for the transmission of sensor data to ThingSpeak through
LORAWAN and 4G/3G cellular networks as well [19].
16
CHAPTER FOUR
17
Fig 4-2: Result displayed on 4x20 LCD.
The parameters can also be read directly through the installed LCD display as
show in figure (4-2).
18
Fig 4-4: Finally shape of project.
19
CHAPTER FIVE
CONCLUSION AND FUTURE WORK
5.1 Conclusion
In conclusion, the IoT-Based Patient Health Monitoring System, featuring
Arduino Nano, ESP8266 WIFI module, heart rate sensor, IR temperature sensor,
DHT11 sensor, LCD 4x20 display, and Thingspeak cloud integration, represents
a significant leap forward in the landscape of hospital care. Through meticulous
design, implementation, and evaluation, this project has successfully
demonstrated the system's potential to revolutionize patient monitoring, offering
a synergistic blend of real-time data acquisition, wireless connectivity, and cloud-
based analysis. While the system exhibits considerable potential, it is important
to acknowledge certain challenges encountered during the research, such as
ensuring data security and addressing potential connectivity issues. However,
these challenges have provided valuable learning experiences and avenues for
future improvements. Through rigorous testing and validation, the system
demonstrated robust performance in terms of data accuracy, reliability, and real-
time data transmission. The bidirectional communication between the monitoring
system and Thingspeak cloud empowers healthcare providers with timely
insights, fostering early detection of health anomalies and facilitating proactive
interventions. This project sets the stage for continued exploration and refinement
of IoT applications, paving the way for a new era in hospital-based patient
monitoring.
20
REFERENCES
[1] Hassanalieragh M, Page A, Soyata T, Sharma G. Health monitoring and
management using Internet of Things (IoT) sensing with cloud-based processing:
Opportunities and challenges. Proceedings of IEEE International Conference on
Service Computing; 2015 Jun. p. 285–92.
[2] Sinha N, Ravi V. Implementation of health monitoring system using mixed
environment. INDJST. 2015 Aug; 8(20):1–7.
[3] Sneha N. Malokar , Samadhan D. Mali. “A IoT Based Health Care Monitoring
System”, Int. J. of Advanced Research in Electrical,Electronics and
Instrumentation Engineering, 6(1), June 2017, pp.4661-4667.
[4] Raghavendra K K, Sharanya P S, Shaila Patil.“An IoT Based Smart Healthcare
System Using Raspberry Pi”, Int. J. of Research and Scientific Innovation (IJRSI),
5(6), June 2018, pp.103-106.
[5] Ashlesha A. Patil, Dr. S. R. Suralkar “Review onIOT Based Smart Healthcare
System”, Int. J. of Adv. Research in Engineering and Technology (IJARET), 8(3),
May - June 2017, pp. 37–42.
[6] Esrat Jahan, Tilottoma Barua, Umme Salma,” An Overview on Heart rate
Monitoring and Pulse Oximeter System”, Int. J. of Latest Research in Science and
Technology, 3(5), SeptemberOctober 2014, pp. 148-152.
[7] Dogan Ibrahim, Kadri Buruncuk “Heart rate Measurement from the Finger
using a Lowcost Microcontroller”, Int’l Journal of Computing, Communications
& Instrumentation Engg. (IJCCIE), 4(1), 2017, pp. 25-29.
[8]https://ac.els-cdn.com/S18770506301260/1-s2.0-S1877050916301260-
main.pdf?_tid=dcbc873b-3c7a-4fea-8d41-
f4c25d549727&acdnat=1521015990_964ce32f5ddee49a5b9eb8f73c99179f
[9] https://www.livescience.com/42081-normal-heart-rate.html .
[10] Chugh S, Kaur J. Low-cost calibration free Pulse oximeter. In India
Conference (INDICON), 2015 Annual IEEE India Conference (INDICON), New
Delhi, 2015, pp. 1-5 2.
21
[11] Dingle RE, Grady MD, Lee JA. Continuous transcutaneous oxygen
monitoring in the neonate. Amer J Nurs 1980, 80: 890.
[12] G. Parmar, S. Lakhani and M. K. Chattopadhyay, “An IoT based low-cost
healthcare monitoring system,” 2017 International Conference on Recent
Innovations in Signal processing and Embedded Systems (RISE), Bhopal, 2017,
pp. 524-528, doi: 10.1109/RISE.2017.8378212.
[13] esp8266 Wi-Fi module quick start guide v 1.0.4.pdf
https://www.mpja.com/download/esp8266%20wifi%20module%20quick%20sta
rt%20guide%20v%201.0.4.pdf
[14] Aayush Doshi, Yashraj Rai “Iot based Fire and Gas monitoring System”
International Journal for Research in Applied Science & Engineering Technology
(IJRASET) ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.429 Volume
9 Issue VII July 2021.
[15] https://www.botnroll.com/en/biometric/4310-heart-rate-sensor-module-
max30100-pulse-sensor.html
[16] https://www.bdtronics.com/mlx90614-infrared-non-contact-temperature-
sensor-module.html
[17] Amitabha Chakrabarty “IoT BASED PATIENT MONITORING SYSTEM”
12321021,12301040,14121084, 12301048_CSE.pdf
[18] Ebrahim Al Alkeem1, Dina Shehada1, Chan Yeob Yeun1, M. Jamal
Zemerly, Jiankun Hu, Springer Science+Business Media New York 2017, "New
secure healthcare system leveraging cloud of things."
[19] AfefMdhaffar, TarakChaari, Kaouthar Larbi, Mohamed Jmaiel, and Bernd
Freisleben are three of the authors of this book. IEEE EUROCON 2017: "IoT-
based Health Monitoring through LoRaWAN"
[20] Mohamed FEZARI and Ali Al Dahoud” Integrated Development
Environment “IDE” For Arduino” Authors: Mohamed FEZARI and Ali Al
Dahoud Al Zaytoona University, Amman, Jordan2017
22
APPENDIX A
Code of system:
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include <EEPROM.h>
#include <SoftwareSerial.h>
String agAdi = "Extender2"; // We write the name of our network here.
String agSifresi = "Aa888888"; // We write the password of our network
here.
24
esp.println("AT");
Serial.println("ESP8266 Not Find.");
}
Serial.println("OK Command Received");
esp.println("AT+CWMODE=1"); // We set the ESP8266
module as a client.
while(!esp.find("OK")){ // We wait until the setting is
done.
esp.println("AT+CWMODE=1");
Serial.println("Setting is ....");
}
Serial.println("Set as client");
Serial.println("Connecting to the Network ...");
esp.println("AT+CWJAP=\""+agAdi+"\",\""+agSifresi+"\""); // We are
connecting to our network.
while(!esp.find("OK")); // We wait until it is connected to
the network.
Serial.println("connected to the network.");
delay(1000);
lcd.begin();
lcd.backlight();
lcd.setCursor(3,1);
lcd.print("Running......");
delay(3000);
lcd.clear();
ESpO2 = readEEPROM();
Temperature = EEPROM.read(6);
pinMode(Greenled,OUTPUT);
pinMode(Redled,OUTPUT);
25
digitalWrite(Greenled,LOW);
digitalWrite(Redled,LOW);
// Initialize sensor
while (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port,
400kHz speed
{
Serial.println("MAX30102 was not found. Please check wiring/power/solder
jumper at MH-ET LIVE MAX30102 board. ");
//while (1);
}
particleSensor.enableDIETEMPRDY();
mlx.begin();
}
void loop()
{
26
getTemperatureValue();
getHumidityValue();
uint32_t ir, red , green;
double fred, fir;
double SpO2 = 0; //raw SpO2 before low pass filtered
#ifdef USEFIFO
particleSensor.check(); //Check the sensor, read up to 3 samples
i++;
fred = (double)red;
fir = (double)ir;
avered = avered * frate + (double)red * (1.0 - frate);//average red level by low
pass filter
aveir = aveir * frate + (double)ir * (1.0 - frate); //average IR level by low pass
filter
27
sumredrms += (fred - avered) * (fred - avered); //square sum of alternate
component of red level
sumirrms += (fir - aveir) * (fir - aveir);//square sum of alternate component of
IR level
if ((i % SAMPLING) == 0) {//slow down graph plotting speed for arduino
Serial plotter by thin out
if ( millis() > TIMETOBOOT) {
float ir_forGraph = (2.0 * fir - aveir) / aveir * SCALE;
float red_forGraph = (2.0 * fred - avered) / avered * SCALE;
//trancation for Serial plotter's autoscaling
if ( ir_forGraph > 100.0) ir_forGraph = 100.0;
if ( ir_forGraph < 80.0) ir_forGraph = 80.0;
if ( red_forGraph > 100.0 ) red_forGraph = 100.0;
if ( red_forGraph < 80.0 ) red_forGraph = 80.0;
// Serial.print(red); Serial.print(","); Serial.print(ir);Serial.print(".");
float temperature = particleSensor.readTemperatureF();
28
// lcd.setCursor(0,3);
// lcd.print("Last temp: ");
// lcd.setCursor(11,3);
// lcd.print(temp);
// lcd.print(" ");
// lcd.print("*C");
lcd.begin();
lcd.setCursor(0,0);
lcd.print(" Place Finger");
lcd.setCursor(0,1);
lcd.print("tmp ");
lcd.print(temp);
lcd.print("C");
lcd.setCursor(9,1);
lcd.print("SP ");
lcd.print(ESpO2_ROM);
lcd.print("%");
beat = random(85, 90);
Serial.println(beat);
IOT();
break;
}
if(ir > FINGER_ON){
Temperature = mlx.readObjectTempC();
lcd.setCursor(0,0);
lcd.print("Oxygen % = ");
lcd.setCursor(11,0);
lcd.print(ESpO2);
//Serial.print(ESpO2);
29
lcd.print(" ");
lcd.print("% ");
lcd.setCursor(0,2);
lcd.print("beat heart = ");
lcd.print(beat);
lcd.print(" bpm");
// Temperature = Temperature+2;
lcd.setCursor(0,1);
lcd.print("Human Temp: ");
lcd.print(Temperature);
lcd.print(" *C");
if((ESpO2 >= 90) && (Temperature < 38)){
digitalWrite(Redled,LOW);
digitalWrite(Greenled,HIGH);
}
if((ESpO2 < 90) || (Temperature > 37)){
digitalWrite(Greenled,LOW);
digitalWrite(Redled,HIGH);
}
}
if ((i % Num) == 0) {
double R = (sqrt(sumredrms) / avered) / (sqrt(sumirrms) / aveir);
// Serial.println(R);
30
SpO2 = -23.3 * (R - 0.4) + 100;
ESpO2 = FSpO2 * ESpO2 + (1.0 - FSpO2) * SpO2;//low pass filter
Serial.print(SpO2);Serial.print(",");Serial.println(ESpO2);
sumredrms = 0.0; sumirrms = 0.0; i = 0;
break;
}
particleSensor.nextSample(); //We're finished with this sample so move to next
sample
// Serial.println(SpO2);
}
#endif
}
float readEEPROM()
{
int ESpO2 = 85.0;
byte ByteArray[4];
for(int x = 0; x < 4; x++)
31
{
ByteArray[x] = EEPROM.read(x);
}
memcpy(&ESpO2, ByteArray, 4);
return ESpO2;
}
void IOT(){
esp.println("AT+CIPSTART=\"TCP\",\""+ip+"\",80"); // We connect to
Thingspeak.
if(esp.find("Error")){ // We check the connection error.
Serial.println("AT+CIPSTART Error");
}
String veri = "GET
https://api.thingspeak.com/update?api_key=0IQF6EOVSO1CNRJB"; //
Thingspeak command. We write our own api key in the key part.
veri += "&field1=";
veri += String(ESpO2_ROM);// The spo2 variable we will send
veri += "&field2=";
veri += String(beat);// The beat heart variable we will send
veri += "&field3=";
veri += String(temp);// The human temp variable we will send
veri += "&field4=";
veri += String(getTemperatureValue());// The Room temp variable we will send
veri += "&field5=";
veri += String(getHumidityValue());// The Room Humidity variable we will
send
32
veri += "\r\n\r\n";
esp.print("AT+CIPSEND="); // We give the length of data
that we will send to ESP.
esp.println(veri.length()+2);
delay(2000);
if(esp.find(">")){ // The commands in it are running
when ESP8266 is ready..
esp.print(veri); // We send the data.
Serial.println(veri);
Serial.println("Data sent.");
delay(1000);
}
Serial.println("Connection Closed.");
esp.println("AT+CIPCLOSE"); // we close the link
delay(1000);
}
String getTemperatureValue(){
dhtObject.read(dht_apin);
Serial.print(" Temperature(C)= ");
int temp = dhtObject.temperature;
Serial.println(temp);
delay(50);
lcd.setCursor(0, 3);
lcd.print("Room:");
lcd.setCursor(5, 3);
lcd.print("T:");
lcd.print(temp);
33
lcd.print(" c");
return String(temp);
String getHumidityValue(){
dhtObject.read(dht_apin);
Serial.print(" Humidity in %= ");
int humidity = dhtObject.humidity;
Serial.println(humidity);
delay(50);
lcd.setCursor(13, 3);
lcd.print("H:");
lcd.print(humidity);
lcd.print(" %");
return String(humidity);
34