     if( (millis() - rmsLastUpdate) > rmsInterval )
     {
         rmsValue = Irms(1);
+        if(!calibrated)
+        {
+            calibrationOffset = rmsValue;
+            calibrated = true;
+        }
+        double measurement = (rmsValue - calibrationOffset) * TENTHOUSAND ;
+        calcAverage(measurement);
         Serial.printf("%d Irms: ", millis());
         Serial.print(rmsValue);
         Serial.println("");

    }
    peakValue = sqrt(value);
    return VTOA * sqrt(sumSquares / (double)samples);
}

void msOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {

double rmsValue = 0.0;
double peakValue = 0.0;

#define NUMMEASURE 24
double twoMinuteMeasurements[NUMMEASURE];
double twoMinuteAverage = 0.0;
double twoMinuteSum = 0.0;
unsigned int MeasurementCounter = 0;
bool enoughMeasurements = false;
bool calibrated = false;

unsigned int globalState = 0;

unsigned int debounceInterval = 200;
unsigned int lastJoystick = 0;
bool triggeredJoystick = false;
