Welcome to Android Central.
The only way to find the cause is to test every part of the charging chain one by one, from wall socket to battery.
Often, the USB lead or USB port are at fault when that happens....test them first.
Posted via the Android Central App