Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15287

The loop speed of mkr wifi 1010 is too slow

$
0
0

https://learn.sparkfun.com/tutorials/smart-home-expansion-kit-for-arduino-101/experiment-9-using-a-current-sensor

Unlike the link, I used mkr wifi 1010, sct-013-000. The rest of the configuration is the same.

The nocktime (t1-t2) being measured now is about 1290m/s, which is too long. I want to reduce this.

The sketches used are as follows.

#include "EmonLib.h"
EnergyMonitor emon1;

double Total = 0;
int count = 0;
double TotalPower = 0;
unsigned long t1 = 0;

void setup() {
Serial.begin(9600);
emon1.current(1, 111.1);

for (int i = 0; i < 5; i++) {
double IrmsNock = emon1.calcIrms(1480);
if (IrmsNock < 0.2) {
Total += IrmsNock;
count++;
}
}

Total /= count;
Serial.print("Average IrmsNock: ");
Serial.println(Total);

t1 = millis();
}

void loop() {
unsigned long t2 = millis();
int nocktime = t2 - t1;
t1 = t2;

double Irms = emon1.calcIrms(1480) - Total;
Irms = (Irms < 0) ? 0 : Irms;

double power = Irms * 220.0;
TotalPower += power * nocktime / 3600.0;

Serial.print(nocktime);
Serial.print(" Current: ");
Serial.print(Irms, 4);
Serial.print(" (A) Power: ");
Serial.print(power, 4);
Serial.print(" (W) Accumulated Power: ");
Serial.print(TotalPower / 1000, 4);
Serial.println(" (W)");
}

Q1. How to reduce nocktime? ,If you reduce the number of samples, it's less accurate

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 15287

Trending Articles