For a project I need to be able to read the battery level of the device regardless of the sketch currently running. For this I plan on adding a custom routine in the Arduino bootloader that reads the battery level and shows it can be accessed even when the current sketch is overwritten with another sketch.
Is creating a custom bootloader a good solution for this? If so how should I go about create that bootloader?
Edit: The battery level will be shown using 3 leds indicator every time a specific button is pressed; I don't want to store the battery level. I need this to happen in every sketch, that's why I think I should do this on the bootloader, having that code on the sketch isn't an option. This is needed because I am developing a custom board and this function will be default on each board.