<?php
function collect_cells(array $modules): array {
    $out = [];
    foreach ($modules as $module) {
        $address = $module['address'] ?? 0;
        foreach ($module['cells'] ?? [] as $cell) {
            $out[] = ['battery' => $address, 'cell' => $cell['cell'] ?? 0];
        }
    }
    return $out;
}

print_r(collect_cells([
    ['address' => 1, 'cells' => [['cell' => 2]]],
    ['address' => 3],
    ['cells' => [['cell' => 4], []]],
]));
