I am trying to power a Nano ESP32 through the USB port using two AA batteries and a 5V voltage booster.
So far this is working except that I would like to monitor the battery level on VBAT so that I can warn the user about the battery discharging and to go into deep sleep when it is nearly fully discharged.
Is there a way to do this without additional circuitry?
The schematic of the Arduino Nano ESP32 board is available by clicking the "Schematics" link under the "DOWNLOADABLE RESOURCES" section of its documentation page here:
Could I put a voltage divider on VUSB and then read the result on one of the Analog pins?
Added: I have just finished running a test where I monitored the state of the 3.3V pin while running a load on my Nano ESP32. Immediately before it 'died' it was still showing 3.3V on that pin. I had hoped that it might have dropped a bit before dying so that I could catch it beforehand. After 'dying' there seemed to be enough current still flowing to cause the Nano ESP32 to constantly reboot and die again. At this point my two AA batteries still showed 2.235V on my voltmeter so not nearly fully discharged.
I suspect that VUSB or VBUS will show a similar behavior - 5V until death - so that would not help me.
It looks like I should put a voltage divider right on the battery box's output, before it goes into the boost converter, and use that to directly monitor the state of my batteries.
You definitly can. Just check that the buck converter works on + and has a common GND (yours has). There are a number of Murata devices that have a common + and work on GND - which could be quite a surprise.
It turns out that I didn't need a voltage divider as the two NiMH AA batteries I am using never deliver more that 3V so I can just monitor the battery output directly using one of the analog pins.
If I do decide to use more batteries then I would need a voltage divider to bring the measured voltage down to 3.3V or lower.