   // KickFFT<int32_t>::fft(fs, 0, 4, FFT_SIZE, fftBuffer, mag, startIndex, endIndex);
   fft_phase(FS, 0, F2, FFT_SIZE, fftBuffer, mag, phase, startIndex, endIndex);
   updatePhase(mag, phase, startIndex, endIndex);
-  float hz = FS * _phaseRateAverage / 2 / PI;
+
+  if (diff > 0) {
+    Serial.print("BPM:\t");
+    for (int i = 0; i < endIndex; i++) {
+      float hz = FS * phaseRateAverage[i] / 2 / PI;
+      float bpm = hz * 60;
+      Serial.print(bpm);
+      Serial.print("\t");
+    }
+    Serial.println("");
+  }
+
+  // float hz = FS * phaseRateAverage / 2 / PI;
   // Serial.print("endIndex: "); Serial.println(endIndex);
   // Serial.print("END_INDEX: "); Serial.println(END_INDEX);
   // Serial.print("BPM: "); Serial.println(hz * 60);
-  //Serial.print("radsPerUpdate: "); Serial.println(_phaseRateAverage);
-
-
-  // each sample changes the phase _phaseRateAverage rads
+  //Serial.print("radsPerUpdate: "); Serial.println(phaseRateAverage);
+
+
+  // each sample changes the phase phaseRateAverage rads
   
  
   // Serial.print("startIndex: ");
   // Serial.print(startIndex);
-  Serial.print("  Mag: ");
-  for (int i = startIndex; i < endIndex; i++) {
-    Serial.print(mag[i]);
-    Serial.print(" ");
-  }
-  Serial.println("");
+  // Serial.print("  Mag: ");
+  // for (int i = startIndex; i < endIndex; i++) {
+  //   Serial.print(mag[i]);
+  //   Serial.print(" ");
+  // }
+  // Serial.println("");
 
   // Serial.print("Phase: ");
   // for (int i = startIndex; i < endIndex; i++) {

	}
}

float _old_phase = 0;
uint16_t _old_max_index = 0;
float _phase_avg = 0;
float _phaseRateAverage = 0;

void updatePhase(const float mag[], const float phases[], uint16_t startIndex, uint16_t endIndex) {
    float maxValue = -1000;

  sht30.begin();
  PDM.onReceive(onPDMdata);
  PDM.begin(1, 16000);
  PDM.setGain(10);

  // init hann window
  for (int i = 0; i < HANN_SIZE ; i++) {
