dc42/arduino

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

Opened this issue · 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);