This question already has an answer here:
I'm working on a battery powered project where I have to constantly monitor the remaining battery level of the battery that is powering the mcu. I know it can be done using arduino and its internal vref. Now, The PIC18F26J50 I'm using also consists of a Band Gap Reference(vref). But I Don't know how to proceed or it's even possible using PIC. Is there a way to monitor the battery level in PIC using this method (or another method)?