Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By trackerj
#48580 For ESP8266 Internal ADC and how to use a voltage divider to scale your input voltage in the desired range you might want to take a look at the related Article/Tutorial : ESP8266 Internal ADC explained. Code example and voltage divider calculations included.
User avatar
By markus_b
#55992 Reading the battery level is not easy. The problem with a voltage divider is, that the voltage divider will consume some current. It is small, but will be significant when always on. Ideally you want to switch it off, when not in use.

But switching it off need additional components, like a pnp transitor to switch it on and a npn transitor to switch the pnp transistor.

Just to make the calculation: Lets assume we use a 10k and a 2.2k transistor to scale 4.5V down to 0.8V. Such a resistor divider consumes 36uA. This is close to 10mAh/day so your 2000mAh LiIon will last 200 days just feeding the resistor divider. By increasing the resistor values you gain time, but loose precision, the above values are on the safe side for good precision. Another aspect is that the resistor divider will continue suckling power until the battery is disconnected. So if you forget a module with the battery connected for a while, then this will drain the battery down to zero, possibly breaking it in the process.