Nernst's equation gives the voltage between two materials in close contact, i.e. the potential difference between the two materials. From the foregoing discussion, we know already two important facts about this potential:  
It will change from one value to the other over a distance across the junction that is given by the (two) Debye lengths of the system.  
The corresponding carrier concentrations are equilibrium concentrations and thus governed by the Boltzmann distribution (considering only classical particles at this point).  
If the potential difference is DU, we thus, using the Boltzmann distribution, obtain for the concentration of the carriers c_{1} in material 1, and c_{2} in material 2:  


This is already Nernst's equation (or law)  in a somewhat unusual way of writing.  
Usually we (and everybody else) use the Boltzmann distribution to compute concentrations as a function of some other known parameters  the energy in this case. But this is not the only way for using a general equation!  
Like any equation, it also works in in reverse: If we know the concentrations, we can calculate the energy difference that must go with them!  
The important point now is that the concentrations of electrons in metals, but also of ions in ionic conductors, or holes in semiconductors, or any mobile carrier a few Debye lengths away from the junction, are fixed  there is no need to compute them!  
What is not fixed is the potential difference e · DU a few Debye lengths away from the junction, and that is what we now can obtain from the above equation by rewriting it for DU:  


This is Nernst's equation in its usual, but somewhat simplified form. We may briefly consider two complications:  
1. If the particles carry z elementary charges, the first factor will now obviously write kT/(z · e).  
2. If the interaction between particles is not negligible (which would mean, e.g., that Ficks law in its simple form would not be usable), the concentrations have to be replaced by the activities a of the particles.  
If you want to know in detail what activities are  use the link. But all you have to know at this point is that activities are the particle concentrations corrected for interaction effects. To give an example: If a particle concentration is 10^{19} cm^{–3}, the activity might only be 5 · 10^{18 }cm^{–3}. If you use this factually wrong number, simple equations like the Boltzmann distribution that do not take into account particle interactions can still be used.  
If the activity numbers are very different from the real concentration numbers, you are no longer doing Materials Science, but chemistry.  
Using this, we obtain the general version of Nernst's law  

Nernsts law, being the Boltzmann distribution in disguise, is of course extremely general. It gives the potential difference and thus the voltage of any contact between two materials that have sufficiently large concentrations of mobile carriers so that an equilibrium distribution can develop. It describes, among other things  
The contact voltage (Volta potential) between two metals (i.e. thermocouples).  
The builtin potential in pnjunctions  
The voltage of any battery or accumulator.  
The voltage of fuel cells.  
The voltage produced by certain kinds of sensors.  
The last issue merits some brief explanation. Let's assume a material with a sufficiently large concentration of mobile O^{–} ions at interstitial sites (in other word, mobile interstitial point defects) at the working temperature  take Y_{2}O_{3} stabilized ZrO_{2} as an example (whatever that may be).  
Use it to measure the amount of oxygen in a given gas mixture with the following oxygen sensor device:  

The sensor material experiences two different oxygen concentrations on its two surfaces, one of which is known (oxygen in air, a constant for all practical purposes), the other one is the concentration in the exhaust gas of a car which is supposed to be measured by the voltmeter  
Two gaspermeable electrodes have been supplied which allow oxygen on both sides to react with the sensor material.  
In equilibrium, we will have some reaction between the oxygen in the gas and the oxygen in the crystal in the sense that oxygen will either come out, or diffuse into the material.  
What we might expect is that the concentration of interstitial oxygen in the crystal will be larger near to the surface with the large oxygen gas concentration (air) compared to the surface exposed to a lower oxygen concentration (exhaust).  
The gradient in the (negatively charged) oxygen concentration inside the material then will be determined by the Debye length of the system (in the real thing, which is ZrO_{2}, it will be just a few nm).  
In total, the concentration [O]_{S} of mobile Ointerstitials right at the surface will be somehow tied to the partial pressure p_{O} of the oxygen on both sides; lets say we have a general relation like  


But any other (reasonable) relation you can think of will be just as good.  
Nernst's law then tells us immediately, how the voltage between the two electrodes depends on the oxygen concentration or partial pressure in the exhaust: For the assumed relation we have  


This is quite remarkable: We have an equation for the voltage that develops across some sensor as a function of the difference of the oxygen concentration on two sides of the sensor without knowing much about the details of the sensor! All we have to assume is that there is some mobile O^{–}, no other free carriers, and that establishing equilibrium does not take forever.  
Only if you want to know the precise value of n do you have to delve into the detailed reactions at the interfaces.  
This is essentially the working principle of not only the oxygen sensor in the exhaust system of any modern car ("l  Sonde"), but of most, if not all, solid state sensors.  

© H. Föll (Advanced Materials B, part 1  script)