Single Lead Heart Rate Monitor - AD8232 - Kit

Introduction

The AD8232 is a neat little chip used to measure the electrical activity of the heart. This electrical activity can be charted as an ECG or Electrocardiogram. Electrocardiography is used to help diagnose various heart conditions.
HeartRateBoardISO_Small-1
Heart_diagram-en.svg
Diagram of the heart.Wikipedia.org

Covered in this Tutorial

In this tutorial, we will go over the basics for getting your AD8232 Heart Rate Monitor up and running. First, an overview of the board and all its features will be presented. Then, we’ll show you how hook it up to your favorite microcontroller and how to create visual data using Processing.

Suggested Reading

If you are not familiar with any of the following concepts, you may want to review them before moving ahead.

What is an Arduino?
Connecting Arduino to Processing
How to Power Your Project
Serial Communication
Serial Terminal Basics
Working with Wire

Understanding the ECG

In general terms, lets look at what an ECG is representing and how we’re able to sense it. The ECG is separated into two basic Intervals, the PR Interval and the QT Interval, described below.
Note: All information comes from the Waves and Intervals section of the ECG Wikipedia page.

EKG_Complex_en.svg
Wikipedia.org

PR Interval

The PR interval is the initial wave generated by an electrical impulse traveling from the right atrium to the left. The right atrium is the first chamber to see an electrical impulse. This electrical impulse causes the chambers to “depolarize”. This forces it to contract and drain deoxygenated blood from both the Superior and Inferior vena cava into the right ventricle. As the electrical impulse travels across the top of the heart it then triggers the left atrium to contract. The left atrium is responsible for receiving newly oxygenated blood from the lungs into the left ventricle via the left and right pulmonary veins. The pulmonary veins are red in the diagram because they are carrying oxygenated blood. They are still called veins because veins carry blood towards the heart. Science!

QT Interval

The QT Interval is where things get really interesting. The QRS is a complex process that generates the signature “beep” in cardiac monitors. During QRS both ventricles begin to pump. The right ventricle begins to pump deoxygenated blood into the lungs through the left and right pulmonary arteries. The pulmonary arteries are blue in the diagram because they are carrying deoxygenated blood. They are still called arteries because arteries carry blood away the heart. Science, Again! The left ventricle is also begining to pump freshly oxygenated blood through the aorta and into the rest of the body. After the initial contraction comes the ST segment. The ST segment is fairly quiet electrically as it is the time where the ventricals waiting to be “re-polarized”. Finally the T wave becomes present to actively “re-ploarize”, or relax the ventricles. This relaxation phase resets the ventricles to be filled again by the atriums.
ECG_principle_slow__1_

Heartbeat with corresponding ECG Wikipedia.org

Connecting the Hardware

In this guide, we’ll connect the AD8232 Breakout to an Arduino microcontroller. We will build a simple cardiac monitor that will allow you to measure the electrical activity of the heart in real time!

Materials required for this example

11301-01SparkFun USB Mini-B Cable - 6 Foot

09873-01aSparkFun FTDI Basic Breakout - 3.3V

00124-04Jumper Wire Kit

00116-02-LBreak Away Headers - Straight
12002-04Breadboard - Self-Adhesive (White)
11114-01Arduino Pro Mini 328 - 3.3V/8MHz
12970-00Sensor Cable - Electrode Pads (3 connector)
12969-00Biomedical Sensor Pad (10 pack)
12650-01SparkFun Single Lead Heart Rate Monitor - AD8232

Pin Connections

The AD8232 Heart Rate Monitor breaks out nine connections from the IC. We traditionally call these connections “pins” because they come from the pins on the IC, but they are actually holes that you can solder wires or header pins to.

HeartRateBoardFront

We’ll connect five of the nine pins on the board to your Arduino. The five pins you need are labeled GND, 3.3v, OUTPUT, LO-, and LO+.

Board Label Pin Function ArduinoConnection
GND Ground GND
3.3v 3.3v Power Supply 3.3v
OUTPUT Output Signal A0
LO- Leads-off Detect- 11
LO+ Leads-off Detect + 10
SDN Shutdown Not used

Connecting Headers to the Board

You can use any method you’d like to make your connections to the board. For this example, we’ll solder on a five-pin length of male-male header strip and use a breadboard and jumpers to make our connections.
Ad8232_headers
Headers installed

Follow the diagram below, to make necessary connections. The SDN pin is not used in this demo. Connecting this pin to ground or “LOW” on a digital pin will power down the chip. This is useful for low power applications.
Heart_Rate_Monitor
Connection Diagram
Now that the electronics are complete, let’s look at sensor pad placement. It is recommended to snap the sensor pads on the leads before application to the body. The closer to the heart the pads are, the better the measurement. The cables are color coded to help identify proper placement.

Cable Color Signal
Black RA (Right Arm)
Blue LA (Left Arm)
Red RL (Right Leg)

FullSetup
Sensors connected to Heart Monitor
body-1
Typical sensor Placements

Uploading the Sketch and Connecting with Processing

By this point, you should have the hardware connected and ready.
The example sketch can be found on github here. You can cut and paste the code straight from github or clone the repository and open the file. For more on using the SparkFun Github repositories, read this handy tutorial. If you’ve never worked with the Arduino IDE before, please see this tutorial.
ArduinoCapture_Anotated
Upload sketch to Arduino Pro-Mini
Now that you have a sketch running, let’s get the processing sketch ready. The processing sketch will give you a visual output of what’s going on. The example processing sketch can be found here. The example Processing sketch works with the Processing IDE v2.2.1. Later versions may not work with the example code so makes sure to download the stable release for v2.2.1 from the Processing IDE Download page.
ProcessingCapture_Anotated
Run the Processing sketch
If the processing sketch does not work, you may need to modify the following line:
myPort = new Serial(this, Serial.list()[2], 9600);
You may need to change the parameter inside Serial.list()[N]. A List of available COM ports will appear in the lower portion of the sketch window. Remember that COM port selection begins at 0. Typically your Arduino will appear as the highest COM number if it is the only device connected to your computer.
ProcessingSketchWindow_Anotated
The Arduino shows up as COM38. This is found in the Serial List at array element “2”.
If everything is working correctly, you should see a nice box pop up and start displaying the output signal.
HeartRate_Normal
“Normal” heart rate of an SFE engineer
If your subject decides to remove the sensors, the leads off detection will kick in and display a flat blue line.
HeartRate_Leads_Off

Tips and Tricks

ECG’s are notoriously noisy. This is because you are measuring muscle activation. The further sensor pads are from the heart, the more muscle noise you will see. These are commonly referred to as “Motion Artifacts”. So here are some simple tips to improve the signal quality.

  1. Keep sensor pads as close to the heart as you can.
  2. Make sure the RA and LA sensor pads are on correct sides of the heart.
  3. Try not to move too much while taking a measurement.
  4. Try to use fresh pads for each measurement.
  5. The pads loose the ability to pass signals with multiple applications.
  6. Prep and clean the area you plan to stick pads.
  7. This will help make a good connection (hair is not a good conductor).
  8. You may have to adjust sensor placement for different individuals.

Resources and Going Further

Thanks for reading. For more resources on the AD8232 Heart Rate Monitor, check out the following links:
AD8232 Datasheet
AD8232 GitHub Repository
For more Electronics Fun, check out these other SparkFun tutorials:
Hacking the MindWave Mobile
Misfit Shine Teardown

More Biometric products offered by MG Super Labs
Pulse Sensor
Muscle Sensor v3 Kit

Document:
GitHub (Design Files & Example Code)

  • Projects

BIO-SMART WEAR

COMPONENTS

  1. Arduino 101 & Genuino 101
  2. SparkFun Single Lead Heart Rate Monitor-AD8232
  3. Texas Instruments Lm35
  4. pulse sensor

NECESSARY TOOLS AND MACHINES

  1. Sport T-Shirt
  2. Soldering iron (generic)
  3. ECG Electrode

APPS AND ONLINE SERVICES

  1. Arduino IDE
  2. node-js
  3. JASON
  4. JaCallVE

ABOUT THIS PROJECT
Design of wearable devices has increased due to the technological revolution of the internet of things (IoT). One of the requirements of IoT that the devices should be small and low-power. Processors and their evolution of the last years, have become a key piece for IoT devices. Intel Edison and Intel Curie are the most recognized technologies in the market and provide all requirements that suit to IoT.

This application is based on this kind of devices to connect the human body to the cloud. The technological market is invaded of a great variety of wearable devices like smart watch or glasses that do not use their full potential in IoT. These devices can only acquire a litter bit part of our Bio-Information. It could be used to monitor our vital sign and create other application to introduce the human into the IoT. For example, The Bio-Smart Wear can be used to monitor patients in their own home or nursing. The future expectations are that all people are connected to the cloud, monitoring their vital signs so that diseases can be detected through clothing.

Bio-SmartWear allows to acquire ECG signal, breathing frequency, body temperature and heart rate.This project is based on an Arduino-101 technology taking advantage of the Ble-Bluetooth and its small size.
Arduino 101 would capture the data using different sensors, as show in the next figure.

001_u0SS3W0xWh
Sensors Distribution

The T-shirt has three sensors: three ECG electrodes, one photo-plethysmography sensor and one temperature sensor. The ECG electrodes need to have a specific configuration such as that described by einthoven triangle.

einthovens_triangle-151b82a5bbd38c0f063_pfJyhdIG2k
Einthoven's Triangle

Using this configuration and an operational amplifier as AD8232 (Figure), it could be possible acquire the ECG signal.

12650-01_gBgO0pMELj
AD8232

The photoplethysmography sensor uses the absorption of light to calculate the beat heart rate.
11574-04_XZJ7GiFlTV
Pulse Sensor

Nevertheless, it is possible change this sensor by a AXREFDES117 to calculate the SPO2. As temperature sensor in this project we use a LM35 ensor which is placed under the armpit. The Arduino 101 is used to acquire the information and is embedded into the T-shirt showed in the next figure:
dibujo1_cudjeladPg
002_NFB4RsClu0
Bluetooth Server

Signals:
ecg_eB0M5m7FfV
Acquired ECG Signal
ppg_ibATp5lOHB
Acquired Photoplethysmography Signal

However it is necessary to incorporate a second hardware in order to introduce an intelligent application. This second hardware is an Intel Edison which is a Bluetooth server and act as a bridge between the smart wear and some artificial intelligent entities. Once data has been captured through Arduino 101 and sent to the Bluetooth server (intel Edisons), it is received by an intelligent entity or agent.

This agent is the representation of the human into the intelligent virtual environment or IVE. Inside the IVE co-exist many agents representing humans and interacting with others agents. The agent acting as virtual representation of the human will have a direct connection with the smart wear. This connection allows to the agent know the human vital sign and be at the same time a container of machine learning algorithm that helps to predict some issues.

To create this IVE we use tools JaCalIVE ().JaCalIVE is a tool that allows to create complex simulations working with multi agent systems. In JaCalIVe we can define the entities that live into an IVE in three blocks : situated, not situated and physical, as is showed in the next figure.
agent_jYeMC8k9QM
Type Of Entities

In this project we use the physical entities such as the human immersed agent. This agent is a representation of the human into the IVE, i.e. the agent is connected to the human.In this case the connection is through the Arduino 101. The agent capture the information sending by the Arduino 101 and it knows the state of the human. The next figure show how the Arduino 101 send the information to the human immersed agent.
1_D0ED0tpRq4
Start Connection with SCARLET

2_me16otXqBK
Arduino 101 Send data through Intel Edison to SCARLET Agent

3_45OhvPqHIj
Close Connection With SCARLET Agent

The next step is to stablish communication between other entities.One a possible entity is a hospital. This hospital can be represented as an agent and if the human immersed agent detects an anomaly in the vital sign, it sends a message to the hospital agent in order to help to the patient. Nevertheless, this part does not take in to account in this project as well as the detection of abnormalities in vital signs is an important topic.

bio_J3kluTO361
Block Diagram

Reference
https://github.com/drejkim/edison-arduino101-iot

SCHEMATICS
Download
circuit_sVbIq8Xc5h.fzz

CODE

#include <CurieBLE.h>
#include <CurieIMU.h>

// Create my own UUIDs; used https://www.uuidgenerator.net/
#define SMARTWEAR_SERVICE_UUID "2947ac9e-fc38-11e5-86aa-5e5517507c66"
#define AX_CHAR_UUID "2947af14-fc38-11e5-86aa-5e5517507c66"
#define AY_CHAR_UUID "2947b090-fc38-11e5-86aa-5e5517507c66"
#define AZ_CHAR_UUID "2947b180-fc38-11e5-86aa-5e5517507c66"
#define GX_CHAR_UUID "2947b252-fc38-11e5-86aa-5e5517507c66"
#define GY_CHAR_UUID "2947b5ae-fc38-11e5-86aa-5e5517507c66"
#define GZ_CHAR_UUID "2947b694-fc38-11e5-86aa-5e5517507c66"
#define ECG_CHAR_UUID "0c3f3508-089a-11e7-93ae-92361f002671"
#define PPG_CHAR_UUID "0c3f38fa-089a-11e7-93ae-92361f002671"
#define TEMP_CHAR_UUID "0c3f38fB-089a-11e7-93ae-92361f002671"

#define TIMER2VAL (1024/(SAMPFREQ))
#define SAMPFREQ 256

// Arduino 101 acts as a BLE peripheral
BLEPeripheral blePeripheral;

// IMU data is registered as a BLE service
BLEService imuService(SMARTWEAR_SERVICE_UUID);

// Each IMU data point is its own characteristic
BLEIntCharacteristic axChar(AX_CHAR_UUID, BLERead | BLENotify);
BLEIntCharacteristic ayChar(AY_CHAR_UUID, BLERead | BLENotify);
BLEIntCharacteristic azChar(AZ_CHAR_UUID, BLERead | BLENotify);
BLEIntCharacteristic gxChar(GX_CHAR_UUID, BLERead | BLENotify);
BLEIntCharacteristic gyChar(GY_CHAR_UUID, BLERead | BLENotify);
BLEIntCharacteristic gzChar(GZ_CHAR_UUID, BLERead | BLENotify);
BLEIntCharacteristic ecgChar(ECG_CHAR_UUID, BLERead | BLENotify);
BLEIntCharacteristic ppgChar(PPG_CHAR_UUID, BLERead | BLENotify);
BLEIntCharacteristic tempChar(TEMP_CHAR_UUID, BLERead | BLENotify);


// Assign pin to indicate BLE connection
const int INDICATOR_PIN = 13;

int ax = 0;
int ay = 0;
int az = 0;
int gx = 0;
int gy = 0;
int gz = 0;
int ecg = 0;
int ppg = 0;
int counter = 0;
float celsius = 0.0;
long previousMillis = 0;

void setup() {

  // Initialize IMU
  Serial.println("Initializing IMU...");
  CurieIMU.begin();
  CurieIMU.autoCalibrateGyroOffset();
  CurieIMU.autoCalibrateAccelerometerOffset(X_AXIS, 0);
  CurieIMU.autoCalibrateAccelerometerOffset(Y_AXIS, 0);
  CurieIMU.autoCalibrateAccelerometerOffset(Z_AXIS, 1);

  // Initialize BLE peripheral
  blePeripheral.setLocalName("SmartWear");
  blePeripheral.setAdvertisedServiceUuid(imuService.uuid());
  blePeripheral.addAttribute(imuService);
  blePeripheral.addAttribute(axChar);
  blePeripheral.addAttribute(ayChar);
  blePeripheral.addAttribute(azChar);
  blePeripheral.addAttribute(gxChar);
  blePeripheral.addAttribute(gyChar);
  blePeripheral.addAttribute(gzChar);
  blePeripheral.addAttribute(ecgChar);
  blePeripheral.addAttribute(ppgChar);
  blePeripheral.addAttribute(tempChar);

  // Set initial values
  axChar.setValue(ax);
  ayChar.setValue(ay);
  azChar.setValue(az);
  gxChar.setValue(gx);
  gyChar.setValue(gy);
  gzChar.setValue(gz);

  ecgChar.setValue(ecg);
  ppgChar.setValue(ppg);

  tempChar.setValue(celsius);


  // Now, activate the BLE peripheral
  blePeripheral.begin();
  Serial.println("Bluetooth device active, waiting for connections...");
}

void loop() {
  // Check if the connection to the central is active or not
  BLECentral central = blePeripheral.central();

  if (central) {
    Serial.print("Connected to central: ");
    Serial.println(central.address());
    digitalWrite(INDICATOR_PIN, HIGH);

    while (central.connected()) {
      updateImuData();
      updatePPG();
      updateECG();
      updateTemperature();
    }

    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
    digitalWrite(INDICATOR_PIN, LOW);
  }
}


void updateECG() {
  int valueECG = analogRead(1);
  ecgChar.setValue(valueECG);
}

void updatePPG() {
  int valuePPG = analogRead(0);
  ppgChar.setValue(valuePPG);
}

void updateTemperature() {
  int value = analogRead(2);
  float millivolts = (value / 1023.0) * 5000;
  celsius = millivolts / 10;
  tempChar.setValue(celsius);
}

void updateImuData() {
  CurieIMU.readMotionSensor(ax, ay, az, gx, gy, gz);

  axChar.setValue(ax);
  ayChar.setValue(ay);
  azChar.setValue(az);
  gxChar.setValue(gx);
  gyChar.setValue(gy);
  gzChar.setValue(gz);
  //gzChar.setValue('\n');

}

SCARLET Agent
jarain78 / SCARLET_Project
Health Care Assistant — Read More

Download as zip

ECG Using Intel Edison and Plotly

FXHUN3AIRDURWJ7.MEDIUM

Electrocardiography is used to help diagnose various heart conditions. Heart rate monitor measures the electrical activity of the heart. This electrical activity can be charted as an ECG or Electrocardiogram.

NOTE: This device is not intended to diagnose or treat any conditions.

With the use of Intel Edison as our IoT device, we will connect a heart rate monitor sensor on Arduino shield of Edison and will measure the electrical activity of the heart in real time! We will then use Plotly (https://plot.ly) to chart our ECG on graphs.

This autonomous combination of hardware, software and networking is now being referred to as IoT (Inter-Operability of Things).

This article assumes you have experience uploading code using Arduino IDE and login to the Edison board using putty.

Step 1: Hardware Components We Will Use in Our Demo

FMGXZE4IQYTLLM3.MEDIUM

F7Z1UY5IQYTLLLV.SMALL

F8SL8H1IQYTLLLR.SMALL

FK19CUAIRDUR3HG.SMALL

F8FX4GGIRDUR5YV.SMALL

  • Intel Edison
  • AD8232 Heart Rate Monitor (Link)
  • ECG Electrodes
  • USB cables
  • Jumper wires

Step 2: Software We Will Write

  • A sketch program running on Edison Arduino shield
    You can download the code samples here.

Step 3: Build the System

FMCJ8BEIRDURGUN.MEDIUM
FPTZ10FIRDURIG5.MEDIUM

Connect the AD8232 Sensor to Edison as shown above.

Board Label Pin Function Arduino Connection

  1. GND Ground GND
  2. 3.3v 3.3v Power Supply 3.3v
  3. OUTPUT Output Signal A0
  4. LO- Leads-off Detect - 11
  5. LO+ Leads-off Detect + 10
  6. SDN Shutdown Not used

Connect the ECG Pads to the audio jack of AD8232 Sensor and attach the pads on body as shown.

Step 4: Connect the Intel® Edison Board to Your Computer for Development

Follow this guide to install Arduino IDE for Edison.

https://software.intel.com/en-us/get-started-arduino-install

  1. Connect the micro usb cable to edison OTG connector.
  2. Connect the micro usb cable to edison serial port connector.
  3. SW1 position towards micro usb connector.

Step 5: Upload the Sketch on Arduino Edison and Using Plotly
FQ9ASFUIRDURSMT.MEDIUM

After installing Arduino for Edison and making proper connections with the computer, upload the sketch provided.

  1. Sign up to plotly: https://plot.ly.
  2. Load up the plotlytry.ino file in Arduino IDE. Fill in your plotly username, API key, stream tokens, and filename. You can find your API key and stream tokens here: https://plot.ly/settings. It'll look something like:

char *tokens[] = {"ab4kf5nfdn","kdf5bn4dbn"};
plotly graph("anna.lyst","ab4kftunvd", tokens, "arduino graph");

  1. Upload the program.
  2. Open up your Serial Monitor. You'll see an output like:

... Attempting to connect to WPA network...

... Connected to network

... Attempting to connect to plotly's REST servers

... Connected to plotly's REST servers

... Sending HTTP Post to plotly

... Sent message, plotly's response:

... A-ok from plotly, All Streams Go!

... View your streaming plot here: https://plot.ly/~streaming-demos/6

... Connecting to plotly's streaming servers...

... Connected to plotly's streaming servers

... Initializing stream

... Done initializing, ready to stream!

  1. Grab the URL that was printed out, view your graph in your browser, and celebrate! The graph and data is saved in your plotly account, so you can view it in your plotly file list here: https://plot.ly/plot. You can view, edit, and share your graphs while data is streaming to them in real-time. Everybody that views the graph will see the exact same data at the same time (try it out yourself: open your graph in two different browser windows).

Step 6: Summary
You can then embed your application directly within an end product and create an E-health device. The real-world application of these principles is just as easy as what you saw. The task complexity is limited only by how much arduino code you are willing to write. Edison seamlessly manage all of the processing handling intricacy in the middle.