arduino icon indicating copy to clipboard operation
arduino copied to clipboard

acs712 in intel edison with adc 12 bits channels - What I need change in below

Open ghost opened this issue 10 years ago • 0 comments

unsigned long currentAcc = 0; unsigned int count = 0; unsigned long prevMicros = micros() - sampleInterval ; while (count < numSamples) { if (micros() - prevMicros >= sampleInterval) { int adc_raw = analogRead(currentPin) - adc_zero; currentAcc += (unsigned long)(adc_raw * adc_raw); ++count; prevMicros += sampleInterval; } }

float rms = sqrt((float)currentAcc/(float)numSamples) * (75.7576 / 1024.0); Serial.println(rms);

ghost avatar Jul 04 '15 15:07 ghost