In this series, we will be building a prototype smart heart monitor. The first part will be setting up the heart monitor with an Arduino.
The Internet of Things is exploding right now when it comes to home automation. However, these are not its limits. I’m fascinated with the Internet of Medical Things and the power that it can bring to healthcare. To further explore this field, I decided to build a smart heart monitor. In this first part I will be building the actual heart monitor. In the second we will look at how to hook it up to the internet and make it a more powerful tool.
For this first part, we will need a few things:
- Arduino Uno
- USB A-to-B cable to power the Arduino Uno
- Heart Monitor Shield from Sparkfun
- Four female header pins to connect the heart monitor to the Arduino
- Jumper Wires
- Heart leads and pads
You can follow the full hookup guide here and get all the code from the heart monitor’s Github. I am putting the must-know sections of each here for ease of reference. The hookup table and lead placement photo is taken from the full guide while the sketches are taken from the heart monitor’s Github.
First, attach the header pins to the heart rate monitor. I used female pins. The Arduino also has female pins, so it will be easy to connect the two with jumper wires.
Second, we will attach the heart monitor to the Arduino Uno accordingly:
|Board Label||Pin Function||Arduino Connection|
|3.3v||3.3v Power Supply||3.3v|
|LO-||Leads-off Detect –||11|
|LO+||Leads-off Detect +||10|
Once that is complete, plug the USB cable into the Arduino and then your PC. You can read Sparkfun’s install guide if this is your first time.
Place the leads onto your body then plug it into the heart rate monitor. Make sure to attach the pads to the leads prior to putting them on your body:
Upload the sketch to the Arduino:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Here, we are setting the communication to a baud rate of 9600. Data coming from LO- and LO+ is used for detecting “lead-off” signal. This is when an electrode is making poor electrical contact. Since this is not valid data (for our purposes), it can be discarded. We will use a “!” to mark invalid data. Lead-off signal can actually be used to detect respiration rates, but we won’t be doing that here. We will consider anything coming from Analog In Pin A0 as valid data.
We then write a sketch in Processing, which will allow us to read and interpret the data from the heart rate monitor. It is important that Processing 2.2.1 is used. If Processing 3 is used, the map function will return NaN (Not a Number) error and it won’t work. This has to do with loss of back-compatibility, so Processing 2 sketches won’t work and the sketch provided is for Processing 2. You can download it here.
Here is the Processing sketch:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
Upload the sketch to the Arduino and then run the Processing sketch. A graph should pop up displaying your heart rate. Pretty cool!
If you are getting a flat blue line, that means no valid data is coming through. You may have to mess with the lead connection going into the heart monitor to start getting valid data in.
If you are having any more problems, you can head over to the tutorial discussion for more troubleshooting advice.
Next up we will explore hooking the heart rate monitor up to Node.js.