Alright, I wanted to tell you all about the air fuel ratio, so here it is...
When the combustion process takes place in an engine, oxygen and nitrogen (air) combine with fuel (hydrocarbons with are basically carbon and hydrogen) and are then ignited, the ideal byproduct should be carbon monoxide and water (CO and H2O). Ironically, science tells us that the optimal power an engine can make is by burning the air/fuel mixture at this perfect rate which is called "stoichiometric." This is when all fuel is perfectly combusted.
But this process is hard to achieve in any kind of engine, especially a car that does not stay in one place all the time. As a car drives, the altitude changes, which affects air density and outside air temperature changes which affects oxygen density and humidity changes depending on the weather and a persons driving habits change how hot the engine coolant and oil get, which also affects how fuel burns efficiently.
With so many factors, it's an automotive nightmare to design enough sensors to accurately measure all of those parameters. The knock sensor, air temperature sensor, MAP or MAF sensor and O2 sensor is some of the best sensors that are used to measure different variables. In the end, all of these sensors tell the engine computer their data so the computer can send the electric pulses to the fuel injectors telling them how much fuel to inject.
The coolest thing with manufacturers tinkering with fuel economy today, is that they're becoming more and more ingenious in how they achieve this stoichiometric equilibrium (and beyond! I'll explain in a minute). The carbuerated engine was a great beginning step, it actually achieved a decent efficiency, but the problem was that it couldn't atomize fuel finely enough at lower RPMs (where most driving is done). Fuel atomization is key to efficiency and this is why... have you ever held a match up to a can of aerosal spray? It lights immediately and completely. Have you ever held a match up to a stream of lighter fluid? It pretty much won't light or it's harder to light. Knowing this is knowing why fuel atomization will help fuel efficiency. If your fuel doesn't atomize in the combustion chamber, when it lights, it won't be completely burnt. If that happens, then you'll get an incomplete burn that is sooty and not making as much power as it could. In a car, this is what would be called "running rich." You might've seen these cars on the street, you'll be able to tell by the excess black smoke coming out of the tailpipe and the smell of fuel or burnt fuel.
Let's get back to stoich for a minute. At sea level, stoicheometric in an engine refers to a combustion process that leaves 14.7 parts air and 1 part fuel by volume. If you are running rich, you will see air fuel ratios of 12 parts air, 1 part fuel or even worse. This means that there is more fuel being injected than can efficiently be burnt. Running lean, however, has a larger part of air to fuel, such as 16:1.
These ratios I was just explaining is what your oxygen sensor tells your engine computer. Based on the conductivity of an electrical circuit inside of the oxygen sensor (oxygen will increase conductivity, therefore changing the electrical system, which is how the O2 sensor works), it will tell your computer the air fuel ratio in your exhaust. Modern day cars have multiple oxygen sensors to recognize consistency and how well your catalytic convertor works.
Oh by the way, for those of you who don't know how a catalytic convertor works, to inside portion has precious metals inside of it (i.e. platinum or pallidium) that react to the exhaust when heated to the right temperatures. When a cat. is warmed up, it will create a chemical process where it bonds the carbon monoxide which is dangerous to humans, to less dangerous carbon dioxide (what we exhale). That is the basic principles of it, but newer cars have hi-tech cats that do much more.
So going to back to O2 sensors, you know that with any automotive part, it degrades over time, which means the signals that it sends to the engine computer might be slightly off. So when you go into Auto Zone or wherever and see their signs that say "replacing your O2 sensor saves and average of $XXX a year" is true, because the air fuel ratio will be better balanced and more accurate. (same is true for spark plugs too
I'll write more on a performance aspect of knowing how your O2 sensors work a little bit later!