Heart Rate Sensor Using Arduino

This example shows how MATLAB® Function is used in Simulink models to read the analog voltage from a heart rate sensor. The MATLAB® function reads the analog voltage from a REES52 heart Rate sensor connected to 'A0' pin on the Arduino Uno board. Arduino Uno board can read voltage between 0 to 5V and returns a number in the range of 0-1023. The MATLAB Function block in the model returns this number. If you hold the sensor, the reading changes. Heart rate can be calculated based on the change in this reading.

A sample image with a heart rate sensor is as shown below.

The hardware connections for R,M, and L, as shown in the above image assumes that the surface of the heart rate sensor with a heart symbol is facing the user. The right-most wire (R) is connected to the analog pin, the middle wire (M) is connected to Vcc and the left-most wire (L) is connected to ground.

  • R - A0

  • M - Vcc (5V)

  • L - GND


Before you start this example, install these MathWorks® products:

  • Simulink Support Package for Arduino® Hardware

  • MATLAB Support Package for Arduino® Hardware

We recommend completing these examples:

Required Hardware

  • Arduino Uno

  • REES52 heart Rate sensor


Configure and Run Models on the Arduino Board

  1. Open the arduino_heart_rate_sensor model.

  2. On the Hardware tab, click Hardware Settings to open the Configuration Parameters dialog box.

  3. Select the Hardware Implementation pane and select your Arduino hardware from the Hardware board parameter list. Do not change any other settings. Click OK.

  4. Click the Deploy to Hardware button to run this model on the Arduino board.

  5. To view the sensor readings on the host computer, run the model using the Monitor and Tune feature. To do this, go to the Hardware tab and click Monitor & Tune.

More About