ANy Sample code for BLE ADC Continuous Data Send
int sent_flag=0; void ub0_interrupt() { sent_flag=1; } void setup() { Serial2.begin(115200); pinMode(PIN_ESP_IO0, OUTPUT); pinMode(PIN_ESP_EN, OUTPUT); digitalWrite(PIN_ESP_IO0, HIGH); digitalWrite(PIN_ESP_EN, LOW); delay(10); digitalWrite(PIN_ESP_EN, HIGH); pinMode(PIN_SW0, INPUT); attachInterrupt(4, ub0_interrupt, FALLING); delay(6000); Serial.begin(9600); while(Serial.available()>0) { Serial.write(Serial2.read()); } setup_ble(); Serial.println("bluetooth initialised"); delay(1000); } void loop() { int analog_value=0; while(1) { analog_value=analogRead(A0); delay(1000); if(sent_flag) { sent_value(analog_value); } } } void sent_value(int value) { int l=len(value); Serial2.print("AT+BLEGATTSNTFY=0,1,6,");Serial2.print(l); send_with_response("",">",500); Serial2.println(value); } int len(int value) { if(value!=0) { int nDigits=floor(log10(abs(value)))+1; return nDigits; } return 0; } void setup_ble() { if(send_with_response("AT+BLEINIT=2","OK",1000)) { Serial.println("bleinit"); } if(send_with_response("AT+BLEGATTSSRVCRE","OK",1000)) { Serial.println("gattcre"); } if(send_with_response("AT+BLEGATTSSRVSTART","OK",1000)) { Serial.println("gattstart"); } if(send_with_response("AT+BLEADVSTART","OK",1000)) { Serial.println("advstart"); } } int send_with_response(char* data_to_send,char* expected_data,int wait_time) { char recieved_data[200]; long cur,prev; int x=0; Serial2.println(data_to_send); cur=millis(); prev=millis(); while((cur-prev)<wait_time) { cur=millis(); if(Serial2.available()>0) { recieved_data[x]=Serial2.read(); Serial.print(recieved_data[x]); x++; } } recieved_data[x]='\0'; Serial.print(recieved_data); if(strstr(recieved_data,expected_data)!=NULL) { return 1; } return 0; }