voltage sensor unstable in my code

Recently there was a thread about analogRead() and reliability. I think it was something with initialization of some prescaler or what else. The sollution was to read twice and discard the first value, like this:

// Other code here...

analogRead(A0); // Initialize ADC, discard this value
vlr_tensao_lambda = analogRead(A0); //port of sensor votage
tensao_lambda=((vlr_tensao_lambda*0.00489)*5); //float to convert A0 result

//More other code here...

Try it and see if it does the trick :slight_smile: