How a Solar Cell Works
A solar cell is made of two types of semiconductors, called p-type and n-type silicon. The p-type silicon is produced by adding atoms—such as boron or gallium—that have one less electron in their outer energy level than does silicon. Because boron has one less electron than is required to form the bonds with the surrounding silicon atoms, an electron vacancy or “hole” is created.
The n-type silicon is made by including atoms that have one more electron in their outer level than does silicon, such as phosphorus. Phosphorus has five electrons in its outer energy level, not four. It bonds with its silicon neighbor atoms, but one electron is not involved in bonding. Instead, it is free to move inside the silicon structure.
A solar cell consists of a layer of p-type silicon placed next to a layer of n-type silicon (Fig. 1). In the n-type layer, there is an excess of electrons, and in the p-type layer, there is an excess of positively charged holes (which are vacancies due to the lack of valence electrons). Near the junction of the two layers, the electrons on one side of the junction (n-type layer) move into the holes on the other side of the junction (p-type layer). This creates an area around the junction, called the depletion zone, in which the electrons fill the holes (Fig. 1, closeup).
When all the holes are filled with electrons in the depletion zone, the p-type side of the depletion zone (where holes were initially present) now contains negatively charged ions, and the n-type side of the depletion zone (where electrons were present) now contains positively charged ions. The presence of these oppositely charged ions creates an internal electric field that prevents electrons in the n-type layer to fill holes in the p-type layer.
When sunlight strikes a solar cell, electrons in the silicon are ejected, which results in the formation of “holes”—the vacancies left behind by the escaping electrons. If this happens in the electric field, the field will move electrons to the n-type layer and holes to the p-type layer. If you connect the n-type and p-type layers with a metallic wire, the electrons will travel from the n-type layer to the p-type layer by crossing the depletion zone and then go through the external wire back of the n-type layer, creating a flow of electricity.
(source from acs.org)