Closed reiyawea closed 1 year ago
Why have you added /2 to the results if they are in mV?
Why have you added /2 to the results if they are in mV?
The analog pin has a 100K+100K voltage divider connected to the battery terminals. So the voltage returned in mV should first /1000 then *2 to be the value of battery voltage in Volt.
Have you tested the result to confirm: Serial.println("Voltage = " + String(voltage)); That result is identical to the original code?
Also only the latest compiler version has added analogreadmillivolts but have you tested all the code with the latest compiler as this no changes the baseline dependencies?
I have tested this code on wemos S2 mini with ESP32 library V2.0.4 and confirmed that nothing changed. All functions are as expected.
Since I'm using a new model of ESP32 board (with new ESP32-S2F chip), the result of the original code is incorrect. So I have to change the code into the one of this PR.
Yea but now the code has to be separated out to an S2 version but also the default ADC resolution is 4096 meaning the original code will still function plus not all boards have the same voltage divider resistor values and therefore the ADC input current offset is varying per board, at the moment I’m leaning towards leaving the code as is because the platform complexity is growing, then adding some readme notes to cover different variants of the ESP32 there is also the C3 version too.
OK I understand the situation. Thank you for your explanation.
Make analog read function return voltage instead of raw ADC data, so as to achieve compatibility across ESP32 series.