Nowadays we see a lot of people placing solar cells on their roof. Solar cells are also known as photovoltaic cells. Photovoltaic comes from the photo which means "light" and voltaic which means "electricity". So basically, a photovoltaic cell uses light to create electricity. But how does it create electricity?
An average photovoltaic (PV) cell consists of 2 layers of silicon where most of the actions happens. It has antireflective coating to prevent the light that goes to the cell reflected away. The cell has metal conductor strips on it to conduct the electricity from the PV cell out to the load. It then gets back to metal backing of the cell to create a close loop.
A common material for silicon is the boron doped silicon and the phosphorus doped silicon. The phosphorus doped silicon contains more electron than the boron doped silicon.
This difference is necessary to create an electric field between the two layers. When these 2 types of silicon are joined together, the electron from the phosphorus doped silicon goes to the boron doped silicon side to create a stable environment. However, this happens only close to the junction of the joining point. Now the cell is ready for producing energy.
Now that the PV cell is ready, the sun comes play in generating energy. The sun sends a wave of photons (although it is also considered as particles of photons) to the earth. These photons have energy and are able to hit the electron in the PV cell. In reaction, the electrons spring out of their orbit and gets to the metal conductor strips.
Note: Pictures are taken from PBS Nova site.