#include "protocentralAds1292r.h" #include "SPI.h" #define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b" //creating the service UUID #define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8" //creating the characteristics UUID #define ESP32_V_SPI_CS_PIN 5 #define ADS1292R_PWRDN_PIN 27 #define ADS1292R_START_PIN 15 #define ADS292R_DATAREADY_PIN 22 char Reg_read_data; bool data_available; #define LED_BUILTIN 2 //pin with LED to turn on when BT connected ads1292OutputValues* ADS1292RegValues; ads1292r ECG_SENSOR_ADS1292R; /*------------------------Setup or main function.---------------------------*/ void setup() { pinMode(ESP32_V_SPI_CS_PIN,OUTPUT); pinMode(ADS1292R_PWRDN_PIN,OUTPUT); pinMode(ADS1292R_START_PIN,OUTPUT); pinMode(ADS292R_DATAREADY_PIN,INPUT); digitalWrite(ESP32_V_SPI_CS_PIN,LOW); digitalWrite(ADS1292R_PWRDN_PIN,LOW); digitalWrite(ADS1292R_START_PIN,HIGH); SPI.begin(); Serial.begin(9600); // define the baud rate of ESP32 Serial.println("Starting BLE work!"); /*-------------------------------------------------------------------------------------------*/ /*-------------Setting up the Sensor------------------------*/ ECG_SENSOR_ADS1292R.ads1292Reset(ADS1292R_PWRDN_PIN); delay(1000); ECG_SENSOR_ADS1292R.ads1292Init(ESP32_V_SPI_CS_PIN,ADS1292R_PWRDN_PIN,ADS1292R_START_PIN); delay(1000); Serial.println("ECG sensor initialised."); data_available = ECG_SENSOR_ADS1292R.getAds1292EcgAndRespirationSamples(ADS292R_DATAREADY_PIN,ESP32_V_SPI_CS_PIN,ADS1292RegValues); data_available=true; if (data_available==true){ Serial.print("The data is ready"); } ECG_SENSOR_ADS1292R.ads1292Reset(ADS1292R_PWRDN_PIN); //For Debug purpose only. //Reading the Chip ID // pinMode(ESP32_V_SPI_CS_PIN,OUTPUT); // pinMode(ADS1292R_PWRDN_PIN,OUTPUT); // pinMode(ADS1292R_START_PIN,OUTPUT); // digitalWrite(ESP32_V_SPI_CS_PIN,LOW); // digitalWrite(ADS1292R_PWRDN_PIN,LOW); // ECG_SENSOR_ADS1292R.ads1292RegRead(ESP32_V_SPI_CS_PIN,ADS1292R_PWRDN_PIN,ADS1292_REG_ID,Reg_read_data); // Serial.println("CHIP ID is:"); // Serial.println(Reg_read_data,HEX); }