Thank you for the code. When i run the code the battery voltage slowly drops from 4.22v to 4.17 whilst in a loop but power is supplied via the dc jack (5V 4A).

When i unplug and plug in the power again the voltage goes back to 4.22V.

Could anybody possible assist?

Thank you