Adding a delay() in sketch

 Would adding a 100ms delay in the 2 channel energy monitor sketch be detrimental to it's accuracy or introduce any problems?

I already have a LED fitted which fulfills a different purpose, and wanted to add a couple of lines that would blink the LED, to indicate that the unit was powered and running. If the delay was say 100ms between LEDon & LEDoff, then the LED  would blink about every 4 seconds.

The second function would switch the LED constantly  on.

TrystanLea's picture

Re: Adding a delay() in sketch

As long as its not in the emon_calc function it will have no determental effect, so anyware amongst the following lines of code is fine:

https://github.com/openenergymonitor/MainsACv3

void loop()
{
  //-------------------------------------------------------------------------------- 
  //--------------------------------------------------------------------------------
  ch1.emon_calc(inPinI_1,ICAL_1); 
  ch2.emon_calc(inPinI_2,ICAL_2); 
  //delay(2000);

  Serial.print("Channel 1 Real Power: "); Serial.println(ch1.realPower);
  Serial.println("");
  Serial.print("Channel 2 Real Power: "); Serial.println(ch2.realPower);

  ch1.wh = ch1.wh + ch1.whInc; //Accumulate wh for channel 1 until ethernet send
  ch2.wh = ch2.wh + ch2.whInc; //Accumulate wh for channel 2 until ethernet send
}

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.