Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Created May 17, 2018 12:37
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 arduinothai/999d51506db905ed66f17e0cf6949948 to your computer and use it in GitHub Desktop.
Save arduinothai/999d51506db905ed66f17e0cf6949948 to your computer and use it in GitHub Desktop.
void setup() {
Serial.begin(9600);
}
void loop() {
float average = 0;
for(int i = 0; i < 1000; i++) {
average = average + (.0264 * analogRead(A0) -13.51) / 1000;
//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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment