When the sun shines on a solar panel, the panel's PV cells absorb the energy from the sun's beams. This energy produces moving electrical charges in response to an internal electric field within the cell, which causes electricity to flow.