Skip to content

Instantly share code, notes, and snippets.

@figital
Created September 24, 2016 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save figital/a5dc8ec0fe63a3b53c1d9ea2c68f2e7f to your computer and use it in GitHub Desktop.
Save figital/a5dc8ec0fe63a3b53c1d9ea2c68f2e7f to your computer and use it in GitHub Desktop.
void setup() {
Serial.begin(9600);
}
void loop() {
float average = 0.00;
float c = analogRead(A5);
int sampleSize = 1000;
for (int i = 1; i <= sampleSize; i++ ) {
average = average + (0.0445 * c - 22.8) / 1000;
//average = .04 * c;
//5A mode, if 20A or 30A mode, need to modify this formula to
//(.19 * analogRead(A0) -25) for 20A mode and
//(.044 * analogRead(A0) -3.78) for 30A mode
delay(1);
}
//Serial.println((average -18.79) * -1);
Serial.println(average);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment