Description
What it is
The MQ-138 sensor is a device designed to detect the presence of various types of gases. It can be used in safety and environmental monitoring projects.
Features
- Detection of various types of gases (check datasheet for specifics)
- Compatibility with Arduino and other microcontrollers (check datasheet)
What it is for
The MQ-138 sensor is ideal for DIY projects such as home alarm systems that send notifications upon detection of hazardous gases or for monitoring air quality in enclosed spaces.
Tutorial: How to use MQ-138
The MQ-138 sensor is a versatile device that detects various types of gases, ideal for DIY projects such as alarm systems or environmental monitoring.
What you need
- Arduino Uno
- USB Connection
- 5V Power Supply
- Pull-up Resistor
Steps
- Connect the MQ-138 sensor to the VCC and GND pins of Arduino to power it.
- Connect the sensor output to a digital or analog pin on the Arduino (check the datasheet).
- Connect a pull-up resistor between the sensor output pin and 5V.
- Download the provided Arduino sketch to read values from the sensor.
- Configure the interrupt on the Arduino to detect changes in the output value (check the datasheet).
- Use a serial monitoring software like Serial Monitor to display the sensor data.
- Calibrate the sensor by exposing it to different types of gases and recording its responses.
- Implement conditional logic in the Arduino code to identify different types of gases based on the detected values.
Example code
// Codice base per leggere i dati dal sensore MQ-138
void setup() {
Serial.begin(9600);
}
void loop() {
int valore = analogRead(pin); // Verifica sul datasheet
Serial.println(valore);
}
Mini project
Create a home alarm system that sends a notification when a dangerous gas is detected.
Common mistakes
- Do not connect the pull-up resistor correctly.
- Ignore the sensor calibration.
- Overload the digital pin with too many devices.
- Use a power supply voltage different from the one specified in the datasheet.
Recommended accessories
- Arduino Uno
- USB Connection
- 16×2 LCD Display
- Buzzer
Frequently asked questions
Does the sensor detect only one type of gas?
No, the MQ-138 is designed to detect a variety of gases.
Do you need to calibrate it before use?
Yes, calibration helps improve the accuracy of the measurements.
Can it work with microcontrollers other than Arduino?
Yes, but it may require code adaptations.





Reviews
There are no reviews yet.