Heart Rate 4 Click Board
Heart Rate 4 Click Board
The Heart Rate 4 Click Board™ is based on the Maxim MAX30101 high-sensitivity pulse oximeter and a heart-rate sensor. The Click Board™ is designed to run on either a 3.3V or 5V power supply.
It communicates with the target MCU over the I2C interface, with additional functionality provided by the INT pin on the MikroBUSline.
Software Support
Code examples for the Heart Rate 4 Click Board™, written for MikroElektronika hardware and compilers are available on Libstock.
CODE SNIPPET
This code snippet initializes the system and display, initializes the board and sets I2C registers. New data from the sensor is collected in a endless loop, via polling and sent via UART to MikroPlot when we are in active heart rate mode.
01 void main( void ) 02 { 03 system_init(); 04 display_init(); 05 hr4_init(); 06 hr4_set_registers(); 07 08 TFT_Set_Font( &HandelGothic_BT21x22_Regular, CL_RED, FO_HORIZONTAL ); 09 TFT_Write_Text( "Use MikroPlot Graph Generator", 10, 100 ); 10 TFT_Set_Font( &HandelGothic_BT21x22_Regular, CL_BLUE, FO_HORIZONTAL ); 11 TFT_Write_Text( "Place Finger On Sensor", 19, 170 ); 12 13 while ( true ) 14 { 15 // Clearing the interrupt by reading the Interrupt Status 1 16 if ( hr4_is_new_fifo_data_ready() & 0x1 ) read_f = true; 17 18 if ( read_f ) // If INT was emitted 19 { 20 read_f = 0; 21 22 if ( !start_f ) // First start 23 { 24 start_f = true; 25 InitTimer1(); // Initializing Timer 1 26 LOG("STARTrn"); // Sending START command to uPlot 27 } 28 29 red_sample = hr4_read_red(); // Read RED sensor data 30 31 LongToStr(miliseconds_counter , txt_milis); 32 LongToStr(red_sample , txt_val); 33 Ltrim(txt_val); 34 Ltrim(txt_milis); 35 36 // If sample pulse amplitude is under threshold value ( proximity mode ) 37 if ( red_sample > 0 && red_sample < 32000 ) 38 { 39 stop_f = true; 40 if ( !no_finger_f ) 41 { 42 TFT_Rectangle( 19, 170, 310, 200 ); 43 TFT_Write_Text( "Place Finger On Sensor", 19, 170 ); 44 } 45 46 no_finger_f = true; 47 } 48 49 // If finger is detected ( we are in active heart rate mode ) 50 else if( red_sample != 0) 51 { 52 stop_f = false; 53 54 if ( no_finger_f ) 55 { 56 TFT_Rectangle( 19, 170, 310, 200 ); 57 TFT_Write_Text( "Generating Graph...", 19, 170 ); 58 } 59 60 no_finger_f = false; 61 62 // Sending data to MikroPlot in format:[pulse_value, milis] via UART 63 LOG(txt_val); 64 LOG(","); 65 LOG(txt_milis); 66 LOG("rn"); 67 } 68 } 69 } 70 }
Heart Rate 4 Click Board
Frequently Asked Questions
Have a Question?
Be the first to ask a question about this.