-->
Page 1 of 4

internal VREF for battery voltage monitoring - edit: Solved

PostPosted: Sat May 30, 2015 3:24 am
by gr0b
Hello, what is the best way to monitor the voltage feed to the ESP8266?

I have created a board that is powered by a lithium cell and instead of a regulator I am using a silicone diode to step the voltage down to a safe value instead of the regulator, This means my input voltage could be anything between about 2.6-3.6V.
I have also added a voltage divider and connected to the ADC pin and the battery but not sure how to best continue from there.

For ATMEGA328 chips I read the vcc by comparing with the internal 1.1v reference voltage then I use this when calculating the battery reading via the voltage divider.

For background the board is a ESP07 with a nRF24L01+ radio and USB charger and lithium protection and i2c to drive an OLED display. Picture attached below.

Re: internal VREF for battery voltage monitoring?

PostPosted: Sat May 30, 2015 2:43 pm
by tytower
While you wait for someone knowledgeable to answer this I'll just throw in my thoughts.

That battery voltage might be still too high to feed the chip and I would just throw another diode in series on it to be sure but ,
the data sheet puts the max at 3.6V and yours could go over perhaps ?

Reading the analog pin should be just the same as reading a pin on the arduino board I would have thought but I hav'nt seen any references to an internal reference voltage in my travels yet.

Maybe there is something herehttps://docs.google.com/file/d/0B9hyK_DA6VIiSWNRZ29sdG1UOVU/edit?pli=1 and maybe in the Wiki on your page now up at the top in black

Re: internal VREF for battery voltage monitoring?

PostPosted: Sun May 31, 2015 1:24 am
by gr0b
Having a look around I can see I did find reference to readvdd33() in a few places, I am not sure how to make use of it but it could solve my issue.

https://github.com/esp8266/Arduino/blob ... g_analog.c

Re: internal VREF for battery voltage monitoring?

PostPosted: Sun May 31, 2015 2:52 am
by gr0b
OK I think I have solved it.

I found some info on using readvdd33 here viewtopic.php?f=33&t=2485

For readvdd33 to work nothing can be connected to the ADC pin, calling Serial.println(readvdd33()>>2); would give the exact value as Serial.println(analogRead(A0)); so by removing the voltage divider from the ADC pin I now get results like 3479 which is looks to be off by about 5%.
For calculating the battery voltage I might have to add the voltage drop from the silicone diode to get a final result