Hello everyone
I'm programming curie nano/genuino 101 board with bluetooth low energy services. I'm currently programming ECG (heart monitor) it is crucial that the device reads and sends values as fast as possible. My ideal target would be 250hz or every 4ms. This is achievable through serial port with no problems, but when I activate bluetooth at those frequencies, bluetooth crashes. My question is what is the highest rate I can update and send via the bluetooth? How can i test it?
I understand that, while the default rate is 9600 baud, the rate can be as high as 1,382,400, but there is no point in discussing it because it appears that both your code and equipment is a secret.
peripheral board - curie nano v1.0 => connected to either android phone, ubuntu laptop or mac, all of them crashes.
code:
#include <CurieBLE.h>
#define printJSON 1
#define BLEenabled 1
BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're programming)
BLEService ecgService("e9f25f8a-474c-4298-938e-7eafa24b9035"); // BLE Heart Rate Service
BLEIntCharacteristic ecgChar("97d9fa60-8fd6-43d5-b018-7cfaa1120bcb", BLERead | BLENotify);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
BLE.begin();
BLE.setLocalName("Life");
BLE.setAdvertisedServiceUuid(ecgService.uuid()); // add the service UUID
ecgService.addCharacteristic(ecgChar);
BLE.addService(ecgService);
BLE.advertise();
}
void loop() {
updateECG();
//delay(30); // does not crash
delay(4); // crashes
}
static void updateECG(){
int heart = analogRead(A0);
if(printJSON) {
Serial.print("{"ecg":");
Serial.print(heart);
Serial.println("}");
}
if(BLEenabled) {
ecgChar.setValue(heart);
}
}
So if you look at the loop, there is one function call with delay of 30ms and 4ms. The one with 4ms crashes while the one with 30ms runs without any problem :). I think the question is to find the minimum viable connection interval. The minimum connection interval of BLE is 7.5ms, in those 7.5ms 8 packets can be exchanged between the devices. 4 packets each direction, so per definition 7,5/4 is the fastest sending rate for a single packet. So im interrested to know the minimum connection interval on the curie nano v1.0.