Melbfella:
I still haven't put the 100nF cap across ground and 5V on the sensor - could you tell me what voltage that cap should be?
Anything above 5V I would assume.
Melbfella:
I still haven't put the 100nF cap across ground and 5V on the sensor - could you tell me what voltage that cap should be?
Anything above 5V I would assume.
Thanks! I'll have to rewire my brain neurons.
Instead of reading a set number of times and averaging the result could you use a function that returns a running average. You could call it as little or often as you like from the main code. It would be less susceptible to sudden temperature fluctuations.
int averageTemp(){
static int runningAverage = analogRead(A0); // When first defined load with current reading
delay(5); // Wait a bit to prevent hammering upsetting ADC
int reading = analogRead(A0); // Read current value
runningAverage = (runningAverage + reading) / 2; // Add current to running and update running
return runningAverage; // Return running average
}
Er, yes. Might take a while to recover after thousands of readings. Plus you want something larger than an int.
I withdraw all that nonsense.
Doing some tests using VB (stuck at work and no Arduino) to see if float would be better than int but after 500 runs the difference is 1 or less so not worth the overhead. Their is a slight difference between running average of 500 numbers and the normal averaging method (add them all up and divide by number) but it may take a mathematician to explain the pros and cons of each method (apart from the obvious memory saving)