// This is BLE based server client model. // This part of the code sends ECG signal from ADS1292R ECG sensor, to the mobile app via ESP32 using the BLE protcol. // This is server code as all the sensors correspond/act like servers which advertise to the client(mobile app) when they are ready to transfer the app. /* VSPI PIN OUT FOR ESP32 CS D5 SCLK D18 MOSI D23 MISO D19 HSPI PIN OUT FOR ESP32 CS D15 SCLK D14 MOSI D13 MISO D12 Here we have VSPI hardware. */ //#include //#include //#include //#include "BLE2904.h" #include "protocentralAds1292r.h" #include "SPI.h" // See the following for generating UUIDs: // https://www.uuidgenerator.net/ #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; /*-----------------Function to detect Lead off condition in ECG.----------------------*/ /*------------------------------------------------------------------------------------*/ /*------------------------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.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1)); delay(100); SPI.begin(); Serial.begin(9600); // define the baud rate of ESP32 /*-------------Setting up the Sensor------------------------*/ //For Debug purpose only. //Reading the Chip ID ECG_SENSOR_ADS1292R.ads1292RegRead(ESP32_V_SPI_CS_PIN,ADS1292R_PWRDN_PIN,ADS1292R_START_PIN,ADS1292_REG_ID,Reg_read_data); Serial.println("CHIP ID is:"); Serial.println(Reg_read_data,HEX); } /*------------------------------------------------------------------------------------*/ void loop() { // put your main code here, to run repeatedly: }