Intro: Heart Rate Monitoring Application Via E-mail
A pulse sensor lets you track your heart rate anytime you want. Imagine being able to track your pulse while you are running or sleeping without the need of special equipment. This can help you to know how healthy your heart is and to detect any anomalies based on continuous measurements of your heart rate. Follow this simple tutorial and build your own pulse monitoring application that continuously tracks your heart rate and sends you emails with the most recent information.
- Intel Edison Arduino Expansion Board
- Pulse Sensor (http://pulsesensor.com/)
- AC Adapter
Step 1: Getting Started With the Pulse Sensor
Follow the getting started guide for the pulse sensor. Go to the next link: http://pulsesensor.com/pages/code-and-guide. Watching the video is enough for this project. Although if you want to make some test with the sensor download the source code for Arduino board.
Step 2: Getting Started With Intel Edison Arduino Expansion Board
Follow the getting started guide for Intel Edison Arduino Expansion Board. Go to the following link: https://software.intel.com/en-us/iot/library/edison-getting-started. Be sure to install Eclipse since a part of the project is developed in C++. Complete the 5 steps. In step 5 read the guide for Eclipse IDE.
Step 3: Circuit Diagram
Make all the required connections (See circuit diagram).
The application is composed of two programs:
- C++ program: It handles everything related with the pulse sensor.
- Node.js program: It sends an e-mail to the user with the sensor information.
The C++ program writes the value obtained from the pulse sensor to a file. Then the Node.js program reads the value from the file and sends it in an e-mail to the user.
The programs communicate and synchronize using the following pins:
Pins controlled by C++ application:
Pin D5: Generates a PWM signal.
Pin D4: Receives the signal from Pin D5. The program generates an interruption every rising edge and the analog pin A0 reads the pulse sensor.
Pin D9: Generates a negative pulse (changes from 1 to 0) when the c++ application has already written the value of the pulse sensor measurement in a file that will also be used by the Node.js application to know the pulse sensor information.
Pin D8: Receives the signal from Pin D7 in the c++ application that informs it that it can continue its execution.
Pins controlled by Node.js application:
Pin D6: Receives the signal from Pin D9 so that the Node.js application knows that it can read the pulse sensor value from the shared file.
Pin D7: Generates a positive pulse (changes from 0 to 1) when the Node.js application has already sent an e-mail with the pulse sensor measurement.
Step 4: Sending an Email With the Intel Edison Board
Download the sendMail.js file and copy it to the Intel Edison Board. You can do this manually by creating a folder called heartRateMonitor in the root directory and then creating a file called sendMail.js inside of this folder. Finally you need to copy the content of the file to the file that you created. A simpler option is to download WinSCP (https://winscp.net/eng/download.php#download2), create a connection and then drag and drop the file in the directory previously mentioned.
Step 5: Configuring Mail Options in SendMail.js
Configure mail options in the sendMail.js file. Find the transporter variable (see figure above). Write your e-mail address in the "user" field and your e-mail password in the "pass" field (you can use a different services such as Hotmail). Then find the mailOptions variable (see figure above) and modify the "from" field and the "to" field. Write your e-mail address and name in the "from" field as well as the e-mail address and name of the person that is going to receive the e-mail in the "to" field.
Step 6: Interacting With the Pulse Sensor
Create a new Project in Eclipse (File -> New -> Intel(R) IoT C/C++ project). Write PulseSensor in the project name and select Empty C++ project. Click Next. Write root as the Connection name and the IP address of the Intel Edison Board (you can get the IP address by connecting to the Board serially and running the command ifconfig. The wlan interface has the address that you are looking for). Click Finish. You will get a folder called PulseSensor and inside the folder a .cpp file with the same name. Replace the content of that file with the content of the PulseSensor.cpp provided below. In the C++ code find a variable called "wait_time", which represents the number of seconds that the application waits before sending each e-mail. It is set to 300 seconds by default, but you can modify it to whichever value you want.
Step 7: Runnig the Node.js Application
Run the sendMail.js file by writing the next command: "node sendMail.js" (be sure your current work directory is the pulseSensor folder). Probably you will get an error because node mailer is not installed. Run the next command to install node mailer: "npm install nodemailer". Run the sendMail.js file again.
Step 8: Executing the C++ Aplication
Run the PulseSensor.cpp file.