How to connect MQ135 to other sensors?

To connect an MQ135 gas sensor with other sensors to your microcontroller (e.g., STM32, Arduino, ESP32), you essentially build a multi-sensor system where each sensor's signal is read through different GPIO or ADC channels. The MQ135 is an analog gas sensor (sometimes with a digital threshold output), so it's easy to integrate with others.
1. Understand the MQ135 Sensor
| Pin | Description |
| VCC | Power supply (typically 5V) |
| GND | Ground |
| AOUT | Analog output (gas level) |
| DOUT | Digital output (threshold set via onboard potentiometer) |
2. Basic Wiring with Other Sensors
Example: MQ135 + DHT11 (temperature) + Hall Sensor
| Sensor | Signal Type | Connect To |
| MQ135 | Analog | ADC pin (e.g., A0) |
| DHT11 | Digital | GPIO with pull-up |
| Hall | Digital | GPIO (interrupt or poll) |
Wiring Example:
plaintext
[ MQ135 ] --> A0 (analog input)
[ DHT11 ] --> D2 (digital GPIO)
[ Hall ] --> D3 (digital GPIO or interrupt)
[ GNDs ] --> Common ground
[ VCCs ] --> 5V (if all support it) or use level shifters
Important: If you're using a 3.3V microcontroller (e.g., ESP32, STM32), and the MQ135 is 5V-only, use a voltage divider or level shifter on the analog line.
3. Power Considerations
MQ135 consumes ~150 mA during warm-up – don’t power it from a weak GPIO pin.
Ensure your 5V rail (e.g., from USB or regulator) can handle total current for all sensors.
4. Reading Sensor Data in Code
Example in Arduino-like pseudocode:
cpp
int mq135_value = analogRead(A0);
int hall_value = digitalRead(D3);
float temperature = dht.readTemperature();
5. Timing & Sampling
MQ135 needs a few minutes warm-up for stable readings.
Avoid reading all sensors at once—use timers or delays to balance CPU load.
Summary
| Sensor | Output Type | Connect To |
| MQ135 | Analog | ADC pin |
| MQ135 | Digital | GPIO (optional) |
| Others | Analog/Digital | ADC or GPIO |
Use shared GND and 5V (or 3.3V) rails
Don’t overload ADC channels — 1 analog sensor per ADC pin
Use voltage dividers if interfacing 5V sensor with 3.3V MCU




