PPM stands for "parts per million", and it is a unit used to measure the concentration of gases in air.

**What Does PPM Mean?**
1 PPM = 1 part of gas per 1 million parts of air
Example:
100 PPM of CO (carbon monoxide) means 100 molecules of CO per 1,000,000 molecules of air
It’s like saying 1 mg of gas per 1 liter of air, though technically it’s a mole/mole ratio in gases.
**How Do Gas Sensors Estimate PPM?**
[Gas sensors](https://www.onzuu.com/category/gas-sensors) like MQ-2, MQ-135 do not directly output PPM. Instead, they measure changes in resistance (Rs) in response to gas exposure, and the PPM is estimated from that using mathematical models.
**1. Internal Working of an MQ Sensor**
* Sensing material: SnO₂ (tin dioxide)
* In clean air: high resistance
* In presence of gas: gas molecules react with adsorbed oxygen → reduces resistance (Rs)
The sensor outputs an analog voltage based on this resistance.
**2. Calculating PPM: From Resistance to Concentration**
**Step 1: Measure Rs (Sensor Resistance)**
Using voltage divider formula:
```
plaintext
Rs = RL × (Vc - Vout) / Vout
```
* RL = load resistor (e.g., 10kΩ)
* Vc = supply voltage (e.g., 5V)
* Vout = analog output voltage
**Step 2: Get R0 in clean air (calibration)**
```
plaintext
R0 = Rs_clean_air / known_ratio_from_datasheet
```
Example:
For MQ-2, clean air ratio is ≈ 9.83 →
R0 = Rs / 9.83
**Step 3: Use Rs/R0 Ratio to Estimate PPM**
From [sensor](https://www.ampheo.com/c/sensors) datasheets, you'll find log-log plots that relate:
```
plaintext
log(PPM) = a × log(Rs/R0) + b
```
Or:
```
c
PPM = pow(10, a * log10(Rs/R0) + b);
```
You derive a and b from the graph for each gas (e.g. LPG, CO, NH₃, etc.)
**Why It's an Estimate**
* MQ [sensors](https://www.ampheoelec.de/c/sensors) are not selective: multiple gases affect Rs
* Environmental factors (humidity, temp) can skew readings
* They are great for trend and threshold detection, not laboratory accuracy
**Example: Estimating LPG Concentration with MQ-2**
```
c
float RL = 10.0; // kΩ
float Vc = 5.0; // volts
float Vout = analogRead(A0) * (5.0 / 1023.0);
float Rs = RL * (Vc - Vout) / Vout;
float R0 = 0.6; // obtained from calibration
float ratio = Rs / R0;
// Approximate for LPG
float ppm = pow(10, -0.47 * log10(ratio) + 1.7);
```
**Summary**
