Design and Implementation of An Infant Monitoring and Control System
Design and Implementation of An Infant Monitoring and Control System
By:
Asmaa Gasiem Elseed Balla Ibrahem
Supervisor:
ض َمثَ ُل نُوِرِه َك ِم ْش َك ٍاة فِ َيها ات َواأل َْر ِ اَّلل نُور ال هسماو ِ
" هُ ُ َ َ
ب ُد ِر ٌّ
ي كَو ك
َ اَ ه
َّنأ ك
َ ة
ُ ج اج الز ِمصباح الْ ِمصباح ِِف زجاج ٍ
ة
ْ ٌ َْ ٌ َْ ُ ُ َ َ َ َ
ٍ ٍِ ٍ ٍ ِ
يُوقَ ُد من َش َجَرٍة مبَ َارَكة َزيْتُونَة ل َش ْرقيهة َول َغ ْربِيهة يَ َك ُ
اد
ور َعلَى نُوٍر يَ ْه ِدي ُه
اَّلل ن ر نَ ه س س
ْ َ ُ ُ َ ْ ْ َ ُْ ٌ ٌَت
َْ َل
َ و ل
َو يء َزي تُها ي ِ
ض
اَّللُ بِ ُك ِل
اس َو ه اَّللُ األَ ْمثَا َل لِلنه ِ
ب ه ِ
ر ض
ْ
َ َ ََ ُ يو اء ش
َ ي ن م ِ
هرِو ن
ُ
لِ
َش ْي ٍء َعلِ ٌيم "
I
Acknowledgement
I will keep on trusting you for .experienced your guidance day by day
my future.
For comments that greatly improved the manuscript and for sharing his
pearls of wisdom, patience, motivations, enthusiasm and immense
knowledge, his guidance helped me in all the time of this research, I am very
grateful for your efforts.
And also special thanks for my families, friends for their encouragement and
supporting me all the time during this research.
Last but not the least; I would like to thank my parents for giving birth to me
at the first place and supporting me spiritually through this research.
II
Abstract
The main aim of this project is to design an infant incubator to measure the
weight, heart rate and Temperature and humidity of baby.
The measurement results which are the pulse rate, temperature and humidity
level, weight and sound have been sent to the PC via Arduino
microcontroller. The advantage of this system will be that in the future, it
may also enable doctors to closely monitor the infant condition and also it’s
provide a database for mothers and send them messages at the time of
feeding. This work is aimed as an example of an application that contributes
towards remote tele-health monitoring system.
III
المستخلص
الحاضنة هي نظام محفز للرضع يستخدم للعناية المركزة لحديثي الوالدة أو الخدج أو المريض.
يوفر بيئة آمنة ونظيفة ،بهواء نقي وظروف محيطة نظيفة ومعقمة لألطفال .باإلضافة إلى ذلك ،
توفر بيئة الحاضنة درجة حرارة متجانسة ومستقرة ،ومستوى رطوبة نسبية ( )RHوتركيز غاز
األكسجين الالزم بشكل خاص للعناية المركزة للطفل الخديج .الهدف الرئيسي من هذا المشروع
هو تصميم حاضنة للرضع لقياس الوزن ومعدل ضربات القلب ودرجة الحرارة والرطوبة للطفل.
في هذه األطروحة ،تم تقديم نظام مدمج يتم مراقبته عن كثب والتحكم فيه بنا ًء على أجهزة
االستشعار .يشتمل النظام المصمم على أجهزة استشعار من ) Arduinoوحدة تحكم دقيقة ووحدة
ضا على
اتصال) وشاشة ومشغالت مثل المروحة ومكبر الصوت ومحرك السائر ,يحتوي النظام أي ً
جزء تطبيق للتواصل مع المستخدمين بشكل مباشر ،ويحتوي على وحدة واجهة المستخدم
الرسومية المرتبطة بقاعدة البيانات التي سجلت قيم معلمات البيئة .يمكن تمكين هذا النظام منخفض
التكلفة والمرن من خالل سيناريو إدارة موثوق به من أجل قياس العالمات الحيوية للطفل.
تم إرسال نتائج القياس وهي معدل النبض ودرجة الحرارة ومستوى الرطوبة والوزن والصوت
إلى جهاز الكمبيوتر عبر متحكم Arduino.وتتمثل ميزة هذا النظام في أنه في المستقبل ،قد يم ّكن
ضا من مراقبة حالة الرضيع عن كثب ،كما أنه يوفر قاعدة بيانات لألمهات ويرسل لهم
األطباء أي ً
رسائل في وقت الرضاعة .يهدف هذا العمل كمثال لتطبيق يساهم في نظام مراقبة الصحة عن بعد
عن بُعد .يوضح النظام الموضح أهمية استخدام أجهزة االستشعار مع قاعدة البيانات في مثل هذه
التطبيقات من الحاضنة .تظهر النتائج التي تم الحصول عليها أدا ًء جيدًا واستجابة للعالمات الحيوية
للطفل.
IV
Table of contents
Subject Page NO
اآلية I
Acknowledgement II
Abstract III
المستخلص IV
Contents V
List Of Figures VIII
List Of Abbreviations IX
Chapter One: Introduction
1
1.1 Introduction
2
1.2 Problem Statement
3
1.3 Aims and Objectives
3
1.4 Methodology
3
1.5 Project Outline
Chapter Two: Theoretical overview and related works
4
2.1 Introduction
2.1.1 Premature Infants 5
incubator
8
2.2 Related Works
2.3 Design parameters 10
2.3.1 Simulation 11
2.3.1.2 Proteus 11
V
2.3.2 Application tools 12
2.3.3.1 Microcontroller 13
2.3.3.4 Potentiometer 17
3.5 Application 26
VI
4.3.4 Sound Sensor Experiment Result 29
4.4 Discussion 33
VII
List of Figures
VIII
List of Abbreviations
NO Abbreviations Denotation
A RPM Remote patient monitoring
B RH relative humidity
C NICU Neonatal intensive care unit
D ICN intensive care unit
E IoT internet of things
F Wi-Fi Wireless Fidelity
G I2C Inter-Integrated Circuit
H IDE Integrated Development Environment
I GUI Graphic User Interface
J LCD Liquid Crystal Display
K IASCI American Standard Code For
Information Interchange
IX
Chapter One
Introduction
1.1 Introduction
Health monitoring systems become a hot topic and important
research field today. Electronic Patient Records and sensor
networks for the patient monitoring are at the current forefront of
new technologies. Remote patient monitoring (RPM) is a
technology which is used to monitoring of the patient from the
remote place or outside the patient’s room or conventional clinical
setup. Advantages of remote patient monitoring are:
1
covered by a rigid clear cover (usually made of plastic, fiber, or
glass).
1.4 Methodology
To achieve the main aims of this thesis, the methodology divided
into three parts. Firstly, simulation part to get the proper circuit that
may provide the project by the ideal circuit design with the suitable
components in order to use the in practical design. Secondly, the
hardware designs part. In this section the conclude results from the
simulation part must be designed practically and made the final
2
circuit design experimentally tests. And finally the application part,
it’s a part that connected the designed system with users (Nurses
and mothers) to monitor and extract the health reports about the
babies.
3
Chapter Two
Theoretical Overview and Related Works
2.1 Introduction
Preterm infants are not capable of maintaining their body temperature
because they have immature thermal regulation systems. This means that
their mechanisms for heat production are under developed and they have
insufficient energy reserves. Therefore, some form of external
thermoregulatory support is vital.
The problem premature and congenitally ill infants is not a new owned.
Stephane Tarnier is generally considered to be the father of the incubator, in
the mid-nineteenth century the infant incubator was first developed based on
the incubators used for chicken eggs. The first use of incubators for the care
of premature infants was in 1722. Trainer (Parisian obstetrician) [2], since
that time the incubator industry witnessed a great development and by 1896
the basic configuration of incubator design was completed and still forms the
basis of today’s incubators. Radiant warmers however are quite new, and
have been only used for nursing ill infants with very low birth weight since
1969 [3].
A neonatal intensive care unit, usually shortened NICU and also called a
Special Care Nursery, newborn intensive care unit, intensive care nursery
(ICN), and special care baby unit, is a unit of a hospital specializing in the
care of ill or premature newborn infants.A NICU is typically directed by one
or more neonatologists and staffed by nurses, nurse practitioners,
pharmacists, physician assistants, resident physicians, and respiratory
4
therapists. Many other ancillary disciplines and specialists are available at
larger units [4].
5
diffuse out. Evaporative heat losses make up a significant fraction of the
total heat loss of a premature infant [5]. The infants have to be kept in the
Intensive Care Unit, when it is suffering from the problems as given in [6].
If the delivery was very difficult, and requires the close observations. In case
of premature/preterm infant (i.e. within7), in which the baby has low birth
weight (less than 1000- 2000 grams, or it is very small in size. If it is
suffering from diseases like Jaundice, Dehydration, or Infections. If the baby
is getting recovered from any critical surgery, or the mother is having a
major disease such as diabetes.
6
gradually as the baby increases in weight. The temperature inside the
mother's womb is 38°C (100.4°F). Leaving the warmth of the womb at birth,
the wet new born finds itself in a much colder environment and immediately
starts losing heat thus the thermal protection of newborns is very important
but not difficult. The basic principles are the same whether the baby is born
at home or in an institution. As most cooling of the newborn occurs during
the first minutes after birth, it is important to act quickly to prevent heat loss.
The new born baby loses heat in four different ways. Heat loss is mainly due
to evaporation of amniotic fluid from the baby's body. But loss of body heat
also occurs by conduction if the baby is placed naked on a cold surface (e.g.
a table, weighing scale or cold mattress); by convection if the naked new
born is exposed to cooler surrounding air; and by radiation from the baby to
cooler objects in the vicinity (e.g. a cold wall or a window) even if the baby
is not actually touching them.
Heat loss increases with air movement, and a baby risks getting cold even at
a room temperature of 30°C (86°F) if there is a draught. Most cooling of the
new born occurs during the first minutes after birth. In the first 10-20
minutes, the new born who is not thermally protected may lose enough heat
for the body temperature to fall by 2-4°C (3.6- 7.2°F), with even greater falls
in the following hours if proper care is not given. If heat loss is not
prevented and is allowed to continue, the baby will develop hypothermia, i.e.
a body temperature below normal. A hypothermic baby, especially if it is
small or sick, is at increased risk of developing health problems and of
dying. However, if heat loss is prevented, the new born will stay warm and
will have a much better chance of remaining healthy, or of surviving if it is
already sick. In trying to keep babies warm, it is important to make sure they
7
do not become overheated. The mechanisms described above may act in
reverse and cause hyperthermia, i.e. a body temperature above normal.
Although less common, hyperthermia is as dangerous as hypothermia [7].
To achieve the main purpose of this project several kind of programs were
used for each part of design, software and hardware even in the application
those will describe them below.
10
2.3.1 Simulation
To write the program and make a simulation for the electrical circuit two
software applications, Arduino Integrated Development Environment (IDE)
and Proteus software were used.
2.3.1.1 Arduino IDE
The Arduino IDE is a cross-platform application written in Java, and derives
from the IDE for the Processing programming language and the Wiring
projects. It is designed to introduce programming to artists andother
newcomers unfamiliar with software development. It includes a code editor
with features such as syntax highlighting, brace matching, and automatic
indentation, and is also capable of compiling and uploading programs to the
board with a single click. A program or code written for Arduino is called a
“sketch”. Arduino programs are written in C language. The Arduino IDE
comes with a software library called “Wiring” from the original Wiring
project, which makes many common input/output operations much easier.
[15]
2.3.1.2 Proteus
Proteus software contains everything you need to develop, test and virtually
prototype your embedded system designs based around the Microchip
Technologies of microcontrollers. The unique nature of schematic based
microcontroller simulation with Proteus facilitates rapid, flexible and
parallel development of both the system hardware and the system firmware.
This design synergy allows engineers to evolve their projects more quickly,
empowering them with the flexibility to make
11
Hardware or firmware changes at will and reducing the time to market.
Proteus VSM models will fundamentally work with the exact same HEX
file, as you would program the physical device with, binary files produced
by any assembler or compiler. We will use ISIS for simulating Arduino
response, it has many variety modeling libraries, and its powerful
concentrates in microcontroller units and microprocessor units modeling.
[16]
12
2.3.3 Hardware tools
In this section of thesis, the hardware components that were used will be
described briefly and there functions.
2.3.3.1 Microcontroller
Mainly in such system (Sign Language Detection System ) based on
Microcontroller .In this system Arduino is a simple microcontroller board
and provides an environment for open source development, that will allow
you to make computers that drive both functional and creative projects alike.
This microcontroller merges the values from all the flex sensors and
provides this input data to server .The Arduino Uno is an open-source
microcontroller board based on the Microchip ATmega328P microcontroller
and developed by Arduino.cc [19].
The board is equipped with sets of digital and analog input/output (I/O) pins
that may be interfaced to various expansion boards (shields) and other
circuits. The board has 14 digital I/O pins (six capable of PWM output), 6
analog I/O pins, and is programmable with the Arduino IDE (Integrated
Development Environment), via a type B USB cable. It can be powered by
the USB cable or by an external 9-volt battery, though it accepts voltages
between 7 and 20 volts Figure 2.2 shows Arduino UNO ports
13
andcomponents.
Fig2.2Arduino kit
14
Fig. 2.3The LCD interface with Arduino.
15
This module includes stickiness and temperature complex with an aligned
computerized sign yield implies DHT11 sensor module is a joined module
for detecting mugginess and temperature which gives an adjusted advanced
yield signal. DHT11 gives exact estimation of moistness and temperature
and guarantees high unwavering quality and long-haul soundness. This
sensor has a resistive sort mugginess estimation segment and NTC type
temperature estimation segment with an 8-piece microcontroller inbuilt
which has a quick reaction and practical and accessible in 4-stick single line
package. DHT11 module deals with sequential correspondence for example
single wire correspondence. This module sends information in type of
heartbeat train of explicit time span. Before sending information to Arduino
it needs some introduce order with a period delay. Furthermore, the entire
procedure time is about 4ms. The single-wire sequential interface makes
framework joining speedy and simple. Its little size, low power usage and
up-to-20-meter signal transmission choosing it the best choice for various
applications, including those most mentioning ones. The segment is 4-stick
single line stick bundle. It is advantageous to interface and uncommon
bundles can be given by clients' solicitation.
DHT11 Specifications:
16
Resolution: Temperature and Humidity both are 16-bit
The sensor can measure temperature from 0°C to 50°C and humidity from
20% to 90% with an accuracy of ±1°C and ±1%. That’s why it was a good
choice for this design. [21]
2.3.3.4 Potentiometer
Regarding the information for preparation of incubators, for infants less than
37 weeks gestational age and/or less than 2 kg body weight must be placed
in the incubator.
17
Potentiometer can be defined as a three-terminal resistor with a variable or
moving contact that divides a voltage into two parts in this thesis
Potentiometer used instead of weight sensor. Figure 2.5 shows the
Potentiometer.
The microphone sound sensor, as the name says, detects sound. It gives a
measurement of how loud a sound is, it have a built-in potentiometer to
18
adjust the sensitivity of the digital output pin. Figure 2.6 shows the sound
sensor. [22]
Is an electronic device that is used to measure the heart rate i.e. speed of the
heartbeat. Monitoring body temperature, heart rate and blood pressure are
the basic things that we do in order to keep us healthy. In order to measure
the body temperature, we use thermometers and a sphygmomanometer to
monitor the Arterial Pressure or Blood Pressure. Heart Rate can be
monitored in two ways: one way is to manually check the pulse either at
wrists or neck and the other way is to use a Heartbeat Sensor. Pulse oximetry
is used in this project to detect the heartbeat using fingers. When the heart
19
expands (diastole) the volume of blood inside the fingertip increases and
when the heart contracts (systole) the volume of blood inside the fingertip
decreases. The resultant pulsing of blood volume inside the fingertip is
directly proportional to the heart rate and if you could somehow count the
number of pulses in one minute, that's the heart rate in beats per minute
(bpm). Figure 2.7 shows the heartbeat sensor. [23]
20
Chapter Three
Methodology
3.1 Introduction
The methodology had been departed into three mainly parts, the Simulation
part to expire the circuit that had been depend on in the design and be sure it
can provide us by the demanded of monitoring and controlling. The second
part is related by the hardware and design the circuit and test it
experimentally. And finally the third parts is contents the Application side
and connect it with the design and record the temperature, humidity, sound
and weight values in database. Heartbeats values displayed as a graph in the
application.
The system is clarified using the flowchart; it is illustrate comparing the set
values with the acquiring values as shown in Fig 3.1.Firstly get the values of
the incubator storage parameters from the sensor and upload these values
into database unit to comparing with acquiring values. If the temperature
greater than the acquired temperature the Arduino send signal to run the fan.
If the baby cries the Arduino send signal to run the stepper motor to swing
the incubator. If the infant’s heart pulse is normal the Arduino send signal to
run the speaker.
21
Fig 3.1 system operation Flowchart
22
sound sensor, a pulse sensor to monitor infant’s heart pulse and pressure
sensor (MPX4115) to measure the baby's weight. An Arduino UNO used to
connect these sensors and communicate between them. In addition, we have
some actuators like fan to control the temperature value around a specific
value (desired value). Also a stepper motor to swing the incubator and
speaker to alarm. These values must send as a frame to save it in a database
in order to use it in the application progress, so that I use a virtual terminal.
Finally I have a display unit to display the temperature and humidity, sound
and weight values, heartbeats values displayed as a graph. We connected all
of these parts by an Arduino kit and wrote all of the above scenarios in code.
And here the designed circuit displayed by details in Fig3.2.
23
3.4 Hardware design
The Proposed Infant Incubator System In this work, an Arduino Uno
microcontroller was used to process the data from sensors. This work also
utilizes a unit of pulse rate sensor. It is a plug-and-play heart sensor that
can detect the pulse per minute for premature babies continuously.
The proposed incubator utilizes a humidity and temperature sensor to
detect humidity and temperature in the incubator to keep the values in
the normal range, then if the temperature moved over 30 the fan will work
to keep it in the desired range and also for humidity, also utilizes sound
sensor when the baby cries the stepper motor will work to swing the
incubator and Variable resistance is used as the weight sensor to measure
the baby's weight. The proposed incubator is also equipped with an LCD
display to show the temperature and humidity inside the incubator,
heartbeats, sound and weight for the baby’s. Furthermore, temperature,
humidity, heartbeats, sound and weight data are processed by the Arduino
and sent to the PC for continuous monitoring. Figure 3.4: shows final
circuit design .And it contains the main components:
1. ARDUINO kit
2. LCD
3. Relay
4. DHT sensor
5. FAN
6. Sound sensor
7. Heartbeats sensor
8. Potentiometer
24
9. ULN 2003 Motor Driver
10. Speaker
25
3.5 Application
Figure 3.4 shows the user interface of the application which used to connect
with arduino to reads the data from arduino and saves it in the
database.From the Application, we can learn all the information about the
baby and extract a report explaining the health status.
The advantage of this system will be that in the future, it may also enable
doctors to closely monitor the infant condition and also it provides a
database for mothers and sends them messages at the time of feeding.
26
Chapter Four
Results and discussion
4.1 Introduction
This chapter presents and discusses the results obtained from simulation
program, Sensors (hardware design) and the application design.
27
4.3 Hardware Results
The monitoring and controlling part, sensing and response part based on
sensors and microcontroller can be there got different result based on
effective environment.
DHT11 sensor is used in this project. The sensor has a fast response time
and low power consumption which is suitable for medical applications.
When the sensor is placed inside the incubator, it will detect the
temperature and humidity around it. The data is transferred to the Arduino
and then processed to be sent to a PC for further analysis. An LCD also will
show the current temperature and humidity inside the incubator. The sensor
will work to ensure that the temperatures of the incubators are always in the
range of 20% ~ 32%. If the reading exceeds the upper limit of this range, a
fan will turn ON.
28
Fig 4.2 Software displaying the pulse rate of an infant.
It was necessary to have a sensor to measure the weight of the child from
one period to another; Variable resistance is used as the weight sensor to
measure the baby's weight.
Each time the baby cries louder, the sensor sends a signal to move the
stepper motor to rotate the incubator to calm his.
29
The third step: start the sensors (DHT, pressure, heartbeats, sound and
weight) send values to Arduino.
The fifth step: the sensors values display on the monitoring screen.
Setting the baud rate and the com of infant incubator that connect with the
central computer to open the connection as shown in Figure 4.3
30
Fig 4.4control interface window between user and system
When the child time of feeds, the program sends a message to the child's
mother as shown in Figure 4.5
Fig4.5Send Message.
From window 4.4 If the Mothers button checked, the next window Fig4.6
will be shown, from this window, it’s able to add Mothers or remove it, and
31
for addition process, it must enter the Mothers information that contains the
Mother name, phone number, the ID, and phone number.
At the end of the system, also can make a report that shows the values of
temperature and humidity pressure, heartbeats, sound and weight from the
day that was stored until this time. Therefore, according to this values can
assist to keep the baby healthy, by using the button report in the Fig 4.7 that
was shown.
32
Fig 4.7incubator report window.
4.4 Discussion
The simulation results are more accurate because it depends only on
changing in value of resistor or sensors to display the output ,as well as in
hard ware the same values had been taken but instead of presented the value
of variable resistor it will present the real value of sense at this moment.
33
Chapter Five
Conclusions and Recommendations
5.1 Conclusion
34
achieved and the system functions as desired in the specifications. The
system provides continuous monitoring of temperature and humidity in the
environment, heartbeats, sound and weight for the baby’s and records this
information’s in database.
5.2 Recommendations
Future development of the system can lead to a more robust system and
more features to be provided for the doctors. The main development can be
mentioned briefly as:
• There are many environments and health parameter can effect on the
health of the baby in the incubator, therefore it’s highly recommended to
include it in the design and study its influence.
• This system were designed for only one incubator, its highly
recommended to involve a different required ranges through a different
nodes with a different values in several incubators to satisfy all incubator
types according to their environmental circumstances and monitored via a
camera then connect all of nodes to make a network using powered
technologies as internet of things (IOT) and control them remotely it would
become more useful.
35
References
1- Journal of Medical Engineering & Technology, Volume 26, Number 2.
March/April 2002.
2- Michael. H. LeBlanc, Thermoregulation: Incubators, radiant warmers,
hoods. ClinPerinatol, 1991. 18: p. 403-422.
3- Gerald B. Merenstein, D.F.K., George L. Brown, Leonard E. Weisman,
Radiant warmers vs incubators for neonatal care. Am J Dis Child, 1979.133:
p. 857- 858.
4- Neonatal intensive care unit. Available from:
http://en.wikipedia.org/wiki/Neonatal_intensive_care_unitthis page was last
edited on 24 February 2021.
5- Prasanga D., H.L., Yael Maguire, Aileen Wu, Design of a Passive
Incubator for Premature Infants in the Developing World. 2002,
Massachusetts Institute Of
Technology, Cambridge, U.S.A
6- (n.d.) Special care: ill or premature babies
Available from:
http://www.nhs.uk/Conditions/pregnancy-andbaby/pages/baby-special-
intensivecare.aspx#close
7- Thermal Protection of newborn: a practical guide, World Health
Organization, Maternal or newborn health/ Safe motherhood unit, Division
of reproductive health (Technical Support) Geneva,
(WHO/RHT/MSM/1997, 2nd Edition).
36
simulation of air flow inside double wall infant incubator by using 3D FEM
’ ,978-1-4799-1467-8/13/$31.00 ©2013 IEEE.
13- Hitu Mittal , Lini Mathew and Ashish Gupta, ‘Design and
Development of an Infant Incubator for Controlling Multiple Parameters’ ,
International Journal of Emerging Trends in Electronics ( IJETEE-
ISSN:2320-9569) , Vol. 11, Issue. 5, Sep-2015.
37
International Journal of Engineering and Advanced Technology (IJEAT)
ISSN: 2249 – 8958, Volume-9 Issue-2.
22- Rajagukguk, Juniastel& Sari, Nurdieni. (2018). Detection System of
Sound Noise Level (SNL) Based on Condenser Microphone Sensor. Journal
of Physics: Conference Series. 970. 012025. 10.1088/1742-
6596/970/1/012025.
23-Prakash, Ved&pandey, manoj. (2018). HEART RATE MONITORING
SYSTEM.
24- Kattwinkel, J., et al. (2010). Part 15: neonatal resuscitation. 2010
American Heart Association Guide-linesfor Cardiopulmonary Resuscitation
and Emergency Cardiovascular Care. 122: 909-919
38
Appendixes
#include <dht.h>
#include <LiquidCrystal.h>
#define USE_ARDUINO_INTERRUPTS true // Set-up low-level
interrupts for most accurate BPM math.
#include <PulseSensorPlayground.h>
//////////////////////////////////////////////////////////////
dht DHT;
floathh;
floattt;
const int fan =9;
const int sou =8;
int sou_val;
int myBPM;
int bed_st,fan_st;
#define DHT11_PIN 7
const int spe =A2;
const int PulseWire = A3;
int Threshold = 550;
LiquidCrystallcd(6, 5, 4, 3, 2, A1);
PulseSensorPlaygroundpulseSensor;
//////////////////////////////////////////////////////////////////
int sensor = A0; // value read from the pot
floatsensorValue;
/////////////////////////////////////////////////////////
39
int motorPin1 = 13;
int motorPin2 = 12;
int motorPin3 = 11;
int motorPin4 = 10;
intdelayTime = 2; // min = 2;
int const steps = 180; // steps ~ 255;
float x;
intvaloareIluminare,dd; // ilumination value
intpas,maxim=0,initializare=1;; // initialization.
//////////// DHT ////////////////////////////////////////////
voiddht_read(){
intchk = DHT.read11(DHT11_PIN);
hh=DHT.humidity;
tt= DHT.temperature;
if(tt<=30){
digitalWrite(fan,LOW);fan_st=0;
}
if(tt>=31){
digitalWrite(fan,HIGH);fan_st=1;
}
}
///////////// voice_sensor//////////////////////////////////////
voidvoice_sensor(){
sou_val = digitalRead(sou);
if (sou_val==HIGH){
40
inita(); bed_st=1;
delay (100);
x=0;
while(x < pas)
{
rotate_clock();
x++;
}}
if (sou_val==LOW){
bed_st=0;
}
}
///////////////////////////weight_sensor//////////////////////
voidweight_sensor(){
sensorValue=analogRead(sensor);
sensorValue = map(sensorValue, 0, 1023, 0, 5);
}
////////////////////PULSE/////////////////////////////////////
Voidpulse () {
MyBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulse
Sensor object that returns BPM as an "int". // "myBPM" hold this BPM
value now.
if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat
happened".
// Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a
message "a heartbeat happened".
41
// Serial.print("BPM: "); // Print phrase "BPM: "
//Serial.println(myBPM); // Print the value inside of myBPM.
} // Assign this value to the "Signal" variable.
42
lcd.print("ECG=");
lcd.print(myBPM);
}
///////////////send data////////////////////////////////////
void Send(){
Serial.print ("*");
Serial.print (",");
Serial.print ("1");
Serial.print (",");
Serial.print (tt);
Serial.print (",");
Serial.print (hh);
Serial.print (",");
Serial.print (sensorValue);
Serial.print (",");
Serial.print (sou_val);
Serial.print (",");
Serial.print (myBPM);
Serial.print (",");
Serial.print (fan_st);
Serial.print (",");
Serial.print (bed_st);
Serial.print (",");
Serial.println ("#");
}
43
///////////////////////////////////////////////////////////
voidrotate_clock() //it rotates ~255 steps (180 grades); [x - number steps]
{clockwise}
{
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
44
/////////////////////////////////////////////////////////////
voidrotate_couterclock() // 260 steps ~
{
digitalWrite(motorPin4, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, HIGH);
delay(delayTime);
45
/////////////////////////////////////////////////////////
voidinita()
{
//if(dd== HIGH){
// initializare=0;
x = steps;
// delayTime = 5; // slowing speed at startup;
while(x > 0)
{
rotate_clock();
delay(2);
if(valoareIluminare> maxim)
{
maxim = valoareIluminare;
pas = x; // saves in 'pas' the step where the max light is;
}
x--;
}
delay(100);
// delayTime = 2; // at return we grow the speed to the maxim, becouse the
sensor will read values only on initialization & not on return to position 0.
while(x < steps) // comes back in position 0;
{
rotate_couterclock();
x++;
46
}
}}
//////////////////////////////////////////////////////////////
Voidsetup ()
{
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(fan,OUTPUT);
pinMode(sou,INPUT);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
//digitalWrite(fan,HIGH);
pulseSensor.analogInput(PulseWire);
//pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino's
LED with heartbeat.
pulseSensor.setThreshold(Threshold);
if (pulseSensor.begin()) {
//Serial.println("We created a pulseSensor Object !"); //This prints one
time at Arduino power-up, or on Arduino reset.
}
pinMode(spe, OUTPUT);
}
///////////////////////////////////////////////////////////////
47
Voidloop()
{
LCD();
dht_read();
voice_sensor();
weight_sensor();
pulse();
delay(1000);
Send();
}
48