NodeMCU and Arduino IDE programing question

For the discussion of Arduino related topics.

Moderator: phalanx

Post Reply
ruddog
Posts: 1
Joined: Thu Nov 15, 2018 8:02 am

NodeMCU and Arduino IDE programing question

Post by ruddog » Thu Nov 15, 2018 8:20 am

As mentioned my board is the NodeMCU and I am writing sketches for it using the Arduino IDE. Currently, the board is set up to read 115 Volt AC current via the SCT-013-30 current sensor. All works well except when the device is first booted up or reset is enacted there is a brief display of current values. This can be seen via the port monitor and they appear to be anomalies for about 10 seconds before they settle down to near zero. I would like to allow a settling time before starting to take current readings. BTW the code is copied from searches via google. Also, I am not a programmer just a hobbyist.

How do I allow the settling time to pass before taking and displaying a reading via port monitor?

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

// Create an instance

void setup()
{

Serial.begin(115200);

emon1.current(A0, 111.1); // Current: input pin, calibration.

}

void loop()
{

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

Serial.print("Apparent Power ");
Serial.print(Irms*230.0); // Apparent power
Serial.print(" ");
Serial.print("Irms ");
Serial.println(Irms); // Irms
delay(2000);
}

Post Reply