"Equation_V_ADC" is wrong
voblaunsane opened this issue · 2 comments
in the debug "Equation_V_ADC" displayed as
v = ADC * A0_max_voltage / 1023
but it should be
v = ADC * A0_max_voltage / 1024
Im using an ESP8266 dev board. The possible analogue pin values range from 0..1023. this amounts to a total of 1024 values!
Hello,
Your observation is correct in the sense that there are 1024 possible values the ADC can take, ranging from 0 to 1023 (inclusive). However, the formula you mentioned:
v = ADC * A0_max_voltage / 1023
Is correct and is widely used when converting ADC readings to voltages. The reason why it's divided by 1023 instead of 1024 is because you're looking for a range that goes from 0 to A0_max_voltage. So, when the ADC reads 1023 (its maximum value), you want that to translate into the maximum voltage. If you divided by 1024, an ADC reading of 1023 would be slightly less than the maximum voltage, which wouldn't be correct.
As for your question about whether a different value can be set on the ADC, it will depend on the board and development platform you're using. Some microcontrollers allow you to configure the ADC resolution, which would change the range of values it can take. In the case of the ESP8266, the ADC resolution is fixed and cannot be changed. The ESP8266's ADC has a 10-bit resolution, which means it outputs 1024 (2^10) different values.
Can you provide me with an example of ADC whose minimum value is not zero to consider the change to 1024 in the library?
you are right!