I have a circuit to calculate my battery level using NodeMCU. I use this formula:
float r1=10.0; // resistor float r2=2.0; // resistor int analogvalue = analogRead(A0); temp = (analogvalue * 3.3) / 1024.0; // nodemcu works 3.3v and analogRead 1v volt = temp / (r2/(r1+r2));
I have to power on/off different sensor to save power. When I calculate the battery level with the following schema I have a correct result: AnalogRead: 213 Battery: 4.12V
The problem is when I put a MOSFET to turnoff the battery calculator. I think that the MOSFET is like a resistor but I am not sure. With the following schema, I have the results: AnalogRead: 136 Battery: 2.63
Can somebody help me? Thanks!