Moderator: igrr
The preferred method is this :-
at the beginning of sketch
ADC_MODE(ADC_VCC); //vcc read
...
//in loop
float vdd = ESP.getVcc() / 1000.0;
If you are using a NodeMCU, there is a voltage divider already on the board! You can choose to use the existing resistors in your calculations or remove them and place higher values as replacements. You can do the resistance-voltage calculations manually, or you can use on of the fancy online Circuit Simulators to quickly design exactly what you want from resistor values you have on-hand. I love Circuit Simulator:
Falstad Original Circuit Simulator Java: http://www.falstad.com/circuit/
Falstad Revised Circuit Simulator javascript
Lush Projects Circuit Simulator javascript: http://lushprojects.com/circuitjs/
Here is an example of where I used a modified NodeMCU and Circuit Simulator to calculate the proper values for a thermistor
Ray
AcmeUK wrote:There is a readvdd33() function but it was causing stack overflows/resets. Not sure if it has been fixed.
The preferred method is this :-
Code: Select allat the beginning of sketch
ADC_MODE(ADC_VCC); //vcc read
...
//in loop
float vdd = ESP.getVcc() / 1000.0;