Setting reading frequency SCT013 current sensor code using Arduino Uno I found this code below for the Arduino platform to obtain current measurements from the SCT013 sensor, and I am wondering how can I define the 'delay' or 'frequency' of my readings? I'd be looking for 200Hz.

Code:

//
#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor emon1;                   // Create an instance

void setup()
{  
  Serial.begin(9600);

  emon1.current(5, 60);             // Current: input pin, calibration.
  //calibration is explained bellow
}

void loop()
{
  double Irms = emon1.calcIrms(1480);  // Calculate Irms only

  Serial.print(Irms*230.0);        // Apparent power
  Serial.print(" ");
  Serial.println(Irms);            // Irms
}
//
you skip reading when the last read is less than 1000/200 = 5ms ago.

unsigned long lastRead;

void loop()
{
   unsigned long currentMillis = millis();
   if(currentMillis - lastRead &gt;= 5){

      double Irms = emon1.calcIrms(1480);  // Calculate Irms only

      Serial.print(Irms*230.0);        // Apparent power
      Serial.print(" ");
      Serial.println(Irms);            // Irms
      lastRead = currentMillis;
    }

}