mq2_pcf8563

Crates.iomq2_pcf8563
lib.rsmq2_pcf8563
version0.1.0
created_at2026-01-23 15:02:01.691714+00
updated_at2026-01-23 15:02:01.691714+00
descriptionNo-std MQ-2 gas sensor logic + PCF8563 RTC support
homepage
repositoryhttps://github.com/olatunbosunoyeleke94/mq2-pcf8563
max_upload_size
id2064704
size27,689
Olatunbosun Oyeleke (olatunbosunoyeleke94)

documentation

README

mq2_pcf8563

crates.io License License

Rust crate for reading MQ-2 gas sensor (ADC) + HZ-8563/PCF8563 RTC (I²C) on Arduino Uno / AVR.

Features:

  • Clean-air baseline calibration
  • Gas index calculation with smoothing
  • Timestamped logging via serial
  • High-gas alert threshold

Hardware Connections

  • MQ-2: VCC → 5V, GND → GND, AOUT → A0
  • HZ-8563/PCF8563: VCC → 5V, GND → GND, SDA → A4, SCL → A5
  • 4.7kΩ pull-up resistors on SDA and SCL to 5V (required for reliable I²C)

Installation

[dependencies]
mq2_pcf8563 = "0.1.0"

For development/testing with Arduino Uno, also add arduino-hal (git dep):


[dependencies.arduino-hal]
git = "https://github.com/Rahix/avr-hal"
rev = "e5c8f37fe48419956e722490a82b9ca9b9fc61a2"
features = ["arduino-uno"]

Usage Example

See the examples/basic_logger.rs for a complete runnable binary that:

  • Calibrates the sensor
  • Logs timestamp + raw + index
  • Prints alert when index exceeds threshold
cargo run --example basic_logger --release

The example uses arduino-hal (git-dependency) and is not part of the published crate on crates.io. Its for development and testing only.

License

Licensed under either of

Contribution

Contributions are welcome! You can help by:

  1. Reporting Issues
  • Found a bug or unexpected behavior? Open an issue on GitHub.
  1. Suggesting Features
  • Ideas for improvements, new sensors, or functionality are always appreciated.
  1. Submitting Pull Requests
  • Fork the repository and make changes in a separate branch.
  1. Ensure your code compiles and follows the project style.
  • Include clear commit messages and, if applicable, update documentation.
  1. Testing
  • Test any new features or fixes on an Arduino with the MQ-2 sensor and PCF8563 RTC (or compatible hardware).

Commit count: 0

cargo fmt