For a school project we're working on a wearable device to track people's movement and heart rate. We use an Arduino Pro Mini with a heartbeat sensor and an accelerometer. The wearable device uses Bluetooth to send data, but only once or twice a day to save battery.
The problem we currently face is having the Arduino keep track of the accelerometer data while also reading the heartbeat sensor on a select interval. See the pseudo-code underneath. In what way (preferably without implementing too many libraries) could we merge these two loops so the accelerometer is read non-stop while keeping an interval (of about 30 minutes) between the heart beat readings? Any input would be greatly appreciated and if needed I can provide additional information.
void loop() {
// Heartbeat sensor loop
while (array is not full) {
delay(30 minutes);
heartbeatArray[index++] = readHeartbeat();
}
sendData_Bluetooth(heartbeatArray);
emptyArray();
// End of heartbeat sensor loop
// Accelerometer loop
while (true)
if (readAccelerometerData > limit)
sendAlert();
// End of accelerometer loop
}
readHeartbeat()
take to execute? What is the accelerometer sampling rate and must it stay consistent?