Hello Réna, thanks for the help.
The code I was working with is available at:
https://github.com/brunotacca/knee_kinematic_sensor/blob/master/SensorCoreApp/SensorCoreApp.inoI kinda mixed both the examples found at tinycircuits learn section.
This:
https://github.com/TinyCircuits/TinyCircuits-TinyShield-Sensor-ASD2511/tree/master/examples/9-Axis_TinyShield_exampleAnd this:
https://github.com/TinyCircuits/TinyCircuits-TinyShield-BLE-ASD2116/tree/master/examples/STBLE/examples/UARTPassThroughIt's still a bit of a mess with a lot of commented code since I am still at the beginning of my research.
The idea I had was to have a concatenated String with the data I need, as you can see in this part:
String msg = "";
msg.concat("C");
msg.concat(sampleCount);
msg.concat("S0");
msg.concat(accelData.x());
msg.concat(accelData.y());
msg.concat(accelData.z());
msg.concat(gyroData.x());
msg.concat(gyroData.y());
msg.concat(gyroData.z());
msg.concat(compassData.x());
msg.concat(compassData.y());
msg.concat(compassData.z());
msg.concat("F");
msg.concat(fusionData.x());
msg.concat(fusionData.y());
msg.concat(fusionData.z());
msg.concat("#");
sendMessage(msg);
And then, send it all truncating it in chunks of 20 bytes.
#define buffer_size 19
void sendMessage(String msg)
{
uint8_t sendBuffer[msg.length() + 1] = {};
msg.getBytes(sendBuffer, msg.length() + 1);
uint8_t sentLength = 0;
int sizeSendBuffer = sizeof(sendBuffer);
while (sentLength < sizeSendBuffer)
{
int arraySize = buffer_size;
if ((sizeSendBuffer - sentLength) < buffer_size)
{
arraySize = (sizeSendBuffer - sentLength);
}
uint8_t sendBufferTruncated[arraySize] = {};
uint8_t sendLength = 0;
while (sendLength < arraySize)
{
if (sendBuffer[sentLength] != 0)
{
sendBufferTruncated[sendLength] = sendBuffer[sentLength];
}
sendLength++;
sentLength++;
}
lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, (uint8_t *)sendBufferTruncated, sendLength);
SerialMonitorInterface.print("SENT> ");
SerialMonitorInterface.println((char *)sendBufferTruncated);
}
}
About the accuracy and the data I need... I do need the more messages I can get per second, and at least, all the sensor data (except for the fusion data maybe). I will be tracking knee movements each steps, so average runners cadence falls at 160ish steps per minute, I will be tracking only one knee so, 80ish steps per minute, which means 1.3 steps per second, a step each 650ms.
With the rate and model I have now, I need like around 60 to 80 bytes of data per full message, which means 4 truncated messages and I had a kind of a stable measurement at 120 ~ `130ms per message (4 messages, so it would send a message each 30ms). A full message per 120ms would mean 5,4 messages per step, this is not good enough for what I had in mind.
This considering I am using only 1 sensor. Since I plan to use 2 wirelings, the data length would double and I would get only 2,7 messages per step.
During this meantime, I found some possible workarounds:
1 - Maybe tinycircuits have a BLE 5.0 available? (the Data Length Extension feature would kinda solve my problem)
2 - Implement all my research in Cpp (which is not my strongest haha) and data fusion in the device itself, sending only my own fusion data.
I appreciate any thoughts you may have.
Thank you in advance.