The are two different types of diodes which may have an important role in the functioning of solar panels (actually the diodes themselves may be identical, it is the way in which they are used which has two possibilities). First let's confirm what a diode is and what it does -
What is a Diode
A diode uses a semiconductor material, usually silicon, with two terminals attached. It's function in it's simplest form is to allow electricity to pass in one direction but not the other.
The diagram to the right shows a simple setup with two panels charging a battery (for simplicity no controller is shown) with a blocking diode in series with the two panels, which are also wired in series. When the sun shines, as long as the voltage produced by the two panels is greater than that of the battery, charging will take place.
However, in the dark, when no voltage is being produced by the panels, the voltage of the battery would cause a current to flow in the opposite direction through the panels, discharging the battery, if it was not for the blocking diode in the circuit.
Blocking diodes will be of benefit in any system using solar panels to charge a battery. Blocking diodes are usually included in the construction of solar panels so further blocking diodes are not required.
Now let's consider what happens if one of the panels in the above diagram is shaded. Not only will that panel not be producing any significant power, but it will also have a high resistance, blocking the flow of power produced by the unshaded panel.
This is where by-pass diodes come into play as shown in the diagram to the right. Now, if one panel is shaded, the current produced by the unshaded panel can flow through a by-pass diode to avoid the high resistance of the shaded panel.
By-pass diodes will not be of use unless panels are connected in series to produce a higher voltage. They are most likely to be of benefit where an MPPT Controller or String Inverter involves panels connected in series to produce voltages well above that items minimum input voltage.
Some solar panels are constructed with the cells divided into groups, each group having a built-in by-pass diode.
Shading of part of a panel may be cuased by a tree branch, debris, or snow.