The first thing that you need to do is to check EACH and EVERY battery terminal connections and also the main ground/body connections for being CLEAN and TIGHT.
Then you need to check the conditon of the battery crossover cable (large positive) that runs between the two batteries...it tends to corrode BENEATH the insulation, just a few inches back from the batteries, and this corrsosion can and will lead to erratic battery volatges, which in turn will lead to corruoption of sensor and ecm oltage and function. Let me repeat this, a poor condition xo cable leads to all sorts of seemingly random problems due yo voltage fluctuations outside of the systes design tolerances. Once these items are checked off the list, you can proceed with other battery diagnostics, but these must be done first to ensure an accurate diagnosis of the charging system simoly because they are crucial/itegral to the proper operation of the charging system, as well as the operation of the trucks ecm and various sensors.