I'm making a wireless temperature sensor node using a STM8L101F3 and 2xAAA batteries with low power considerations. The MCU lacks an ADC and to measure battery level I'm thinking about using a few zeners or voltage-reference chips and some digital IO to figure it out. 3 voltage levels have to be measured (over 2.7v
, between 2.2v and 2.7v
and under 2.2v
) and the requirements are as below:
- IO powered. To overcome power consumption, I'd like to turn on a GPIO, read another digital GPIO and turn it all off; each micro-amp counts. Tri-state IOs are available.
- Not so precise. 0.1V deviation is well tolerated. hysteresis is optional.
- TL431(2.5v VREF) and TLV431(1.25v VREF) are preferred; but it's fine if it's possible using simple zeners.
- Worst-case temperature range is about -20c up to 80c
- The supply voltage range is about 2v up to 3v based on various battery chemistries.
I tried to do something like this, but got lost into resistor selection :
So is it possible to do that using a few digital-only GPIOs?