GebraBit

ADS1292R Sensor Project With Arduino

متن سربرگ خود را وارد کنید

ADS1292R

ADS1292R Sensor Project With Arduino

  1. Home
  2. »
  3. medical
  4. »
  5. ADS1292R Sensor Project With Arduino

What's the purpose of this project?

The project aims to interface the ADS1292R sensor with Arduino for real-time ECG and respiration monitoring. Ideal for applications like portable health devices, fitness trackers, and medical research, it provides accurate physiological data to enable responsive and reliable health monitoring systems.

What are we going to learn in this tutorial?

In this tutorial, you’ll learn how to:

  • Connect the ADS1292R sensor to Arduino and establish SPI communication.
  • Configure and use an existing library to enable ECG and respiration data acquisition.
  • Read and interpret physiological signals in real-time, understanding data for medical and fitness applications.
  • Implement sensor-based projects for portable health monitoring, gaining practical skills for creating responsive systems based on ECG and respiration measurements.

This hands-on guide provides insights into sensor integration and real-time physiological data monitoring with Arduino.

What do we need to start this project?

As you probably know, we need some hardware and software to do this project. The titles of these hardware and software are provided to you in the table below and you can prepare/download by clicking on each of them and get ready to start.

Required hardware
Required software
Arduino UNO
Logic Level Converter

First as shown in the image below, we connect the GebraBit APDS9306 module to the Arduino UNO as follows:

Then download and add the GebraBit ADS1292R library to your Arduino IDE.

Arduino
ADS1292R
Color
D11 (MOSI)
SDI
Gold
D12 (MISO)
SDO
Yellow
D13 (SCK)
SCK
Brown
D10 (SS)
CS
Gray
D4
RST
Green
D6
RDY
Purpule
D5
STA
Orange
3V3
3V3
Red
5V
5V
Blue
GND
GND
Black

The provided library and code are designed for the default jumper settings (as shown in the image above). If the jumper settings are changed, modifications to the code may be required based on the sensor’s datasheet and module schematic. Please note that changing the jumper settings can affect the functionality of the sample code available on the website.

 

After connecting the Arduino to the module using a Logic Level Converter, download the ADS1292R library and add it to the Arduino software.

Required Library

If you don’t know how to add GebraBit libraries to Arduino IDE, refer to the tutorial link below.

ECG Lead Connection

 

To connect the device to the body, a 3-lead ECG cable with a male headphone jack is used. In 3-lead ECG cables, the leads are color-coded as red, green, and yellow. The red lead is connected to the right arm, the yellow lead to the left arm, and the green lead to the right leg of the person.

By connecting the male headphone jack of the ECG cable to the corresponding socket on the module and properly attaching the leads, the module is activated, and heart rate monitoring is performed.

There are various methods for attaching these three leads to the body, and the method mentioned is just one of them. Before attaching the leads, be sure to clean the target area with alcohol. Dust, grease, or hair on the surface can reduce the quality of the signals received by the module and affect measurement accuracy.

APDS9306 library and driver

In addition to the modular design of various sensors and ICs, GebraBit tries to provide variety of structured and hardware-independent libraries in C language for the ease of users in setting up and developing software.

For this purpose, after preparing each GebraBit module, the users can refer to the “tutorial” section of the desired module and download the dedicated library, which contains the “ .h” and “  .cpp” file (Header and Source) and a sample training program under “GebraBit STM32F303”, “GebraBit ATMEGA32A” or “Arduino” development boards.

All the defined functions and structures in the library are commented in full detail and all the received parameters in the arguments of the functions and their return values, are briefly explained. Since the libraries are hardware independed, the user can easily add the library in any of their favorite compilers and develop it by desired microcontroller and development board.

Sample program in Arduino

After connecting the module to Arduino and adding the library to the IDE, go to the following path: File > Examples > ADS1292R > ECG_RES_Plotter

Description of Sample file

The module’s connections to the Arduino are mentioned in the comments at the top of the code.
				
					//  |ads1292r pin label| Arduino Connection   |Pin Function      |
//  |----------------- |:--------------------:|-----------------:|
//  | VDD              | +5V                  |  Supply voltage  |
//  | PWDN/RESET       | D4                   |  Reset           |
//  | START            | D5                   |  Start Input     |
//  | DRDY             | D6                   |  Data Ready Outpt|
//  | CS               | D10                   |  Chip Select     |
//  | MOSI             | D11                  |  Slave In        |
//  | MISO             | D12                  |  Slave Out       |
//  | SCK              | D13                  |  Serial Clock    |
//  | GND              | Gnd                  |  Gnd             |
				
			
The required libraries for setting up the sensor have been imported into the program.
				
					#include "ADS1292R.h"
#include "ecgResAlgorithm.h"
#include <SPI.h>
				
			
If you have connected the module’s DRDY (RDY), CS, START (STA), or PWDN (RST) pins to different Arduino pins, modify the code below according to your specific connections.
				
					const int ADS1292_DRDY_PIN = 6;
const int ADS1292_CS_PIN = 10;
const int ADS1292_START_PIN = 5;
const int ADS1292_PWDN_PIN = 4;
				
			
As you know, the ADS1292R sensor has two channels: the first channel provides ECG data (electrocardiogram), and the second channel provides Respiration data. To view the results in the Arduino Plotter, you can comment out the third line to see the first channel’s ECG data or comment out the second line to see the second channel’s Respiration data. (Note: To view the output on the Plotter, be sure to use an older version of Arduino software (version 1.8.20 or earlier)).
				
					    //if you want ecg data comment second line and if you want res datas on plotter comment first line and uncomment second line
    Serial.println(ecgFilterout);
    //Serial.println(resWaveBuff);
				
			
For example, the output of the above code in the Arduino Plotter shows ECG data, while the output of the code below shows Respiration data.
				
					    //if you want ecg data comment second line and if you want res datas on plotter comment first line and uncomment second line
    //Serial.println(ecgFilterout);
    Serial.println(resWaveBuff);
				
			

The Sample file code text:

				
					//////////////////////////////////////////////////////////////////////////////////////////
//
//   Arduino Library for ADS1292R Shield/Breakout
//
//   Copyright (c) 2017 ProtoCentral
//   Heartrate and respiration computation based on original code from Texas Instruments
//
//   This is a simple example to plot ECG through arduino serial plotter.
//
//   This software is licensed under the MIT License(http://opensource.org/licenses/MIT).
//
//   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
//   NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
//   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
//   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
//  |ads1292r pin label| Arduino Connection   |Pin Function      |
//  |----------------- |:--------------------:|-----------------:|
//  | VDD              | +5V                  |  Supply voltage  |
//  | PWDN/RESET       | D4                   |  Reset           |
//  | START            | D5                   |  Start Input     |
//  | DRDY             | D6                   |  Data Ready Outpt|
//  | CS               | D10                   |  Chip Select     |
//  | MOSI             | D11                  |  Slave In        |
//  | MISO             | D12                  |  Slave Out       |
//  | SCK              | D13                  |  Serial Clock    |
//  | GND              | Gnd                  |  Gnd             |
//
/////////////////////////////////////////////////////////////////////////////////////////


#include "ADS1292R.h"
#include "ecgResAlgorithm.h"
#include <SPI.h>

volatile uint8_t globalHeartRate = 0;
volatile uint8_t globalRespirationRate=0;

const int ADS1292_DRDY_PIN = 6;
const int ADS1292_CS_PIN = 10;
const int ADS1292_START_PIN = 5;
const int ADS1292_PWDN_PIN = 4;

int16_t ecgWaveBuff, ecgFilterout;
int16_t resWaveBuff,respFilterout;

ads1292r ADS1292R;
ecg_respiration_algorithm ECG_RESPIRATION_ALGORITHM;

void setup()
{
  delay(2000);

  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  //CPOL = 0, CPHA = 1
  SPI.setDataMode(SPI_MODE1);
  // Selecting 1Mhz clock for SPI
  SPI.setClockDivider(SPI_CLOCK_DIV16);

  pinMode(ADS1292_DRDY_PIN, INPUT);
  pinMode(ADS1292_CS_PIN, OUTPUT);
  pinMode(ADS1292_START_PIN, OUTPUT);
  pinMode(ADS1292_PWDN_PIN, OUTPUT);

  Serial.begin(57600);
  ADS1292R.ads1292Init(ADS1292_CS_PIN,ADS1292_PWDN_PIN,ADS1292_START_PIN);
  Serial.println("Initiliziation is done");
}

void loop()
{
  ads1292OutputValues ecgRespirationValues;

  boolean ret = ADS1292R.getAds1292EcgAndRespirationSamples(ADS1292_DRDY_PIN,ADS1292_CS_PIN,&ecgRespirationValues);
  if (ret == true)
  {
    ecgWaveBuff = (int16_t)(ecgRespirationValues.sDaqVals[1] >> 8) ;  // ignore the lower 8 bits out of 24bits
    resWaveBuff = (int16_t)(ecgRespirationValues.sresultTempResp>>8) ;

    if(ecgRespirationValues.leadoffDetected == false)
    {
      ECG_RESPIRATION_ALGORITHM.ECG_ProcessCurrSample(&ecgWaveBuff, &ecgFilterout);   // filter out the line noise @40Hz cutoff 161 order
      ECG_RESPIRATION_ALGORITHM.QRS_Algorithm_Interface(ecgFilterout,&globalHeartRate); // calculate
      //respFilterout = ECG_RESPIRATION_ALGORITHM.Resp_ProcessCurrSample(resWaveBuff);
      //ECG_RESPIRATION_ALGORITHM.RESP_Algorithm_Interface(respFilterout,&globalRespirationRate);

    }else{
      ecgFilterout = 0;
      respFilterout = 0;
    }
    //if you want ecg data comment second line and if you want res datas on plotter comment first line and uncomment second line
    Serial.println(ecgFilterout);
    //Serial.println(resWaveBuff);
  }
}
				
			

Connect your arduino to computer and select your Arduino Board

Then Verify and Upload the Sample code

After uploading the code, go to Tools > Serial Plotter and then you can see module output

Make sure to set the BaudRate to 57600; otherwise, you will not receive correct data.

Below, you can download the ADS1292R library, schematic, and module datasheet.

Program output video

Output Ch1 ECG Video:

Play Video

Output Ch1 ECG Photo:

Output Ch2 Respiration Photo:

این مقاله را با دوستانتان به اشتراک بگذارید!

Be the first to write a review

Please help the Gebra team to improve the quality by sending comments and ratings

Your email address will not be published. Required fields are marked *

Shopping cart
Start typing to see posts you are looking for.

Sign in

No account yet?