mq135 0.1.0

Rust embedded driver for MQ135 air quality sensor
Documentation
# mq135

![Crates.io](https://img.shields.io/crates/v/mq135?style=flat-square)  
![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)  
![Rust](https://img.shields.io/badge/rust-embedded--hal-orange?style=flat-square)

---

## πŸš€ Overview

**mq135** is a minimal, `#![no_std]` Rust driver for the **MQ135 air quality sensor**.  
It’s designed for embedded systems using the [`embedded-hal`](https://crates.io/crates/embedded-hal) ADC traits.

The MQ135 sensor detects air quality by measuring gases like COβ‚‚, NH₃, Benzene, and Smoke via analog voltage readings. This driver converts those readings into gas concentration (PPM).

---

## ✨ Features

- βœ… Calibration support in clean air  
- βœ… Measures PPM values for multiple gases (COβ‚‚, NH₃, Benzene, Smoke)  
- βœ… Uses generic `embedded-hal` traits for wide MCU compatibility  
- βœ… No standard library (`#![no_std]`), perfect for microcontrollers  
- βœ… Easy-to-use API for quick integration  

---

## πŸ“¦ Usage

First, add the crate to your dependencies:

```toml
[dependencies]
mq135 = "0.1"  # replace with latest version
embedded-hal = "0.2"  # or your compatible version
libm = "0.2"  # for math in no_std environment
````

Example code snippet:

```rust
use mq135::{Mq135, GasType};

// `adc` must implement `embedded_hal::adc::OneShot`
// `pin` is the ADC input pin connected to MQ135 sensor output

let mut sensor = Mq135::new(adc, pin, 10_000.0); // RL load resistance in Ohms

// Calibrate the sensor in clean air before readings
sensor.calibrate_in_clean_air().unwrap();

// Get gas concentration in PPM
let co2_ppm = sensor.read_gas_ppm(GasType::CO2).unwrap();

println!("CO2 Concentration: {:.2} ppm", co2_ppm);
```

---

## πŸ§ͺ Calibration

Calibration is necessary to set the baseline sensor resistance (`R0`) in clean air. This ensures accurate gas concentration measurements.

---

## 🌬️ Supported Gases

| Gas     | Description          |
| ------- | -------------------- |
| COβ‚‚     | Carbon Dioxide       |
| NH₃     | Ammonia              |
| Benzene | Aromatic Hydrocarbon |
| Smoke   | General Smoke Levels |

---

## βš™οΈ Dependencies

* [`embedded-hal`]https://crates.io/crates/embedded-hal β€” Hardware abstraction layer for embedded devices
* [`libm`]https://crates.io/crates/libm β€” Math functions compatible with `no_std` environments

---

## πŸ“„ License

This project is licensed under the **MIT License** Β© 2025 Prabesh Shrestha.

---

## 🀝 Contributions

Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/prabesh-shrestha/mq135/issues).

---

Thank you for using **mq135**!
Happy coding and clean air monitoring! 🌿