MDM9206 with Heart Rate Sensor

Skill LevelArea of FocusOperating SystemPlatform/HardwareCloud Services/Platform
IntermediateHealthcare, SensorsRTOSMDM920x LTE for IoTGizwits Cloud Platform

This project is designed to use a heart rate sensor with the Qualcomm® MDM9206 LTE modem, and when the detected data is higher than the set threshold, the LED light is illuminated.

The main objective of this project is to connect the heart rate sensor to the ADC interface of the MDM9206 modem provided by the GoKit development board and collect heart rate information. The LED is designed to turn ON when the detected heart rate is higher than the threshold value.

Parts used

Below are the items used in this project:

  1. Win7 PC
  2. Pulse Sensor, used to collect heart rate information
  3. LED, when the detected heart rate value exceeds the set threshold, the LED lights up
  4. DuPont cable, used to connect other components as wires
  5. Oscilloscope, used to view the detected heart rate waveform in real time

Parts used for the GoKit4 development kit demo-Smart-Heart-rate-detector

Parts used for the GoKit4 development kit demo-Smart-Heart-rate-detector

How does it work?

The application is designed to upload the data to the Gizwits cloud. Below are the different functions implemented in the project.

Now let's introduce the demo-smart-heart-rate-detector’s workflow.

  void gagentMain(void)

The function named "gagentMain" was called by "GAgent". The main role of GAgent is data forwarding, which is a data interaction bridge between device data, Wit Cloud, and application end (APP). Function "sensorInit" does the sensor initialization:

  void sensorInit(void)
    gizLog(LOG_INFO, "Sensor initialization ...\n");
  void led_init()
    gizLog(LOG_INFO, "in led init...\n");
    led_on_off(false, led_red);
  void Pulsesensor_init()
    qapi_Status_t status = QAPI_ERROR;
    const char *Channel_Name_ADC0 = ADC_INPUT_ADC0;
    qapi_Timer_Sleep(2, QAPI_TIMER_UNIT_SEC, true);
    status = adc_open_handle();  
    if(status != QAPI_OK)
      //IOT_DEBUG("Get ADC Handle ERROR!");
      gizLog(LOG_INFO,"adc open handle error...\n");
    status = adc_get_properties(Channel_Name_ADC0, &Properties_ADC0);
      if(status != QAPI_OK)
      //IOT_DEBUG("Get ADC channel-%s Configuration ERROR!", Channel_Name_ADC1);
      gizLog(LOG_INFO,"Get ADC channel-%s Configuration ERROR...\n", Channel_Name_ADC0);
  qapi_Status_t timer_init(void)      //init 
              qapi_Status_t status = QAPI_OK;
              memset(&timer_def_attr, 0, sizeof(timer_def_attr));
    timer_def_attr.cb_type	= QAPI_TIMER_FUNC1_CB_TYPE;
    timer_def_attr.deferrable = false;
    timer_def_attr.sigs_func_ptr = timer1_handler;
    timer_def_attr.sigs_mask_data = 0x11;
    status = qapi_Timer_Def(&timer_handle, &timer_def_attr);
              return status;
  qapi_Status_t timer_start(void)
      qapi_Status_t status = QAPI_OK;
              memset(&timer_set_attr, 0, sizeof(timer_set_attr));
    timer_set_attr.reload = 100;
    timer_set_attr.time = 10;
    timer_set_attr.unit = QAPI_TIMER_UNIT_MSEC;
    status = qapi_Timer_Set(timer_handle, &timer_set_attr);
              return status;
  void timer1_handler(uint32_t data)         // timer callback
    static bool led_red_status = true;
    getHeartRateValue(&heartrate);            //get heartvalue
    if(!heartrate)	                                       //no  value		
    else if(((heartrate > HEART_RATE_THRESHOLD_HIGH) || (heartrate  (IBI/5)*3)   // avoid dichrotic noise by waiting 3/5 of last IBI
      if(Signal  thresh && Signal > P)		// thresh condition helps avoid noise
      P = Signal;                             // P is the peak,keep track of highest point in pulse wave
      gizLog(LOG_INFO,"Find peak, P = %d\n", P);
    // signal surges up in value every time there is a pulse
    if (Num > 600)			
    {                                   // avoid high frequency noise	
      if ( (Signal > thresh) && (Pulse == false) && (Num > (IBI/5)*3) )
        Pulse = true;        // set the Pulse flag when we think there is a pulse
        IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS
        lastBeatTime = sampleCounter;               // keep track of time for next pulse
        if(secondBeat)	                  // if this is the second beat, if secondBeat == TRUE
          secondBeat = false;   // clear secondBeat flag
          for(int i=0; i 2500)
    {                           // if 2.5 seconds go by without a beat
      thresh = 512;                          // set thresh default
      P = 512;                               // set P default
      T = 512;                               // set T default
      lastBeatTime = sampleCounter;          // bring the lastBeatTime up to date        
      firstBeat = true;                      // set these to avoid noise
      secondBeat = false;                    // when we get the heartbeat back
  1. Download code from GitHub repository: “
  2. Compile the code and flash the image to GoKit4 development kit.
  3. Connect the heart rate sensor to the ADC1 channel of the GoKit development board.
  4. Connect one pin of the led to the D9 pin of the development board, and the other pin is connected to the Vcc.
  5. Turn on the oscilloscope, adjust to the appropriate gear position, connect the heart rate sensor's pulse signal output pin and GND to the oscilloscope.
  6. Use the USB data cable to connect the PC and GoKit development board.
  7. Touch your finger to the signal acquisition surface of the heart rate sensor.
  8. Open the serial debugging assistant, and you can see the collected data in real time.

When the detected data exceeds the threshold, you can see that the LED is lit.

Zhen[email protected]Thundersoft
Rong[email protected]Thundersoft
Jie[email protected]Thundersoft
Kou[email protected]Thundersoft
Eric[email protected]Thundersoft