# A Crowdsensing Platform for Monitoring of Vehicular Emissions: A Smart City Perspective
## 4 Soft Sensor for Pollution Monitoring
### Speed Density  
The second estimation method used in this work can be considered more complex than the previous one. It is performed on the basis of the ideal gas law, also called the ideal gas equation (perfect gas). In this law of physics, we observe a series of relations between the temperature, pressure, and volume of the gas. First enunciated by [PERSON] in 1834, Equation (7) is the mathematical representation of this law. \[P\cdot V=n\cdot R\cdot T \tag{7}\]  
The terms of Equation (7) are explained as follows:  
* **P** represents the pressure in the combustion chamber and can be obtained by means of the MAP (Manifold Absolute Pressure) sensor in KPa. * **V** is the volume of the combustion chambers in the engine cylinders and can be measured in units of volume as Liters (L) or cubic centimeters (cm\({}^{3}\)). * **R** is the ideal gas constant. Its value is approximately 8.3145 \(\frac{\mathrm{J}}{\mathrm{mol\cdot K}}\). * **T** is the gas temperature. It can be obtained by the IAT (Intake Absolute Temperature) sensor in K.
* **n** is the number of moles in the sample. The idea behind the speed density method is to find the amount of moles (\(n\)) of a given amount of air flowing through the air intake before the combustion. Equation (8) shows how this value can be found rearranging the terms in Equation (7). \[n=\frac{P\cdot V}{R\cdot T} \tag{8}\]  
Knowing that the \(n\) represents the number of moles in the sample, we can find the mass of air (\(m_{air}\)) by multiplying it by the molecular weight (molar mass, represented by \(M_{air}\)) of the air, as described in Equation (9). \[m_{\text{air}}=n\cdot M_{\text{air}} \tag{9}\]From Equation (9), one can isolate \(n\) and obtain the number of moles as a ratio of the air mass and its molar mass. This value can be substituted in Equation (8) in order to obtain Equation (10). \[\frac{m_{\text{air}}}{M_{\text{air}}}=\frac{P\cdot V}{R\cdot T} \tag{10}\]  
Finally, the air mass can be obtained by reordering the terms in Equation (10) in the form shown in Equation (11), which will serve as basis for the formula derived later in this subsection to estimate the amount of CO\({}_{2}\). \[m_{\text{air}}=\frac{P\cdot V}{R\cdot T}\cdot M_{\text{air}} \tag{11}\]  
However, Equation (11) is only valid if the engine has a Volumetric Efficiency (VE) of 100%. VE is the ratio between the air-fuel mixture volume that each cylinder admits and the nominal cylinder capacity. For example, in a 2.0 four-cylinder engine, each cylinder has a nominal volumetric capacity of 500 cm\({}^{3}\), but due to inlet losses, the cylinder only admits around 400 cm\({}^{3}\). In that case, the engine has a volumetric efficiency of 80%. The VE can be found using the following relation:  
\[VE=\frac{V_{intake}}{V_{nominal}}\times 100\% \tag{12}\]  
where:  
* \(V_{intake}\) represents the real volume of intake air supported by the cylinders. * \(V_{nominal}\) is the theoretical volume of the engine. Therefore, we must take into account the volumetric efficiency of the engine together with its volume, so Equation (11) becomes Equation (13). \[m_{\text{air}}=\frac{P\cdot V}{R\cdot T}\cdot M_{\text{air}}\cdot VE \tag{13}\]  
Thus, using Equation (13) coupled with the engine Revolutions Per Minute (RPM), we can finally obtain the mass of air flowing through the intake at any given time. To accomplish that, one must find out how many RPM the engine is working, a value that can be obtained via OBD-II. During the vehicle operation, considering a four-stroke engine, there are two steps of air intake, i.e., in a complete cycle, air flows inside the engine twice. With that information, we can calculate the number of times air enters the engine per second by dividing the RPM by \(2\times 60\). Incorporating this into (13) gives us the mass air flow (\(m_{air}\)), shown by (14). \[\dot{m}_{air}=\frac{P\cdot V}{R\cdot T}\cdot M_{\text{air}}\cdot VE\cdot \frac{RPM}{120} \tag{14}\]  
The value obtained by this equation corresponds to an equivalent to that obtained directly by the MAF sensor in Section 4.3.