The MQ-138 sensor is an electrochemical gas sensor designed for the detection of formaldehyde (HCHO) in the air. It is widely used in various applications such as indoor air quality monitoring, industrial safety, and environmental protection. The sensor's high sensitivity and fast response time make it an ideal choice for detecting formaldehyde concentrations in real-time.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (5V) |
2 | GND | Ground |
3 | DOUT | Digital output (TTL logic level) |
4 | AOUT | Analog output (proportional to HCHO) |
Q: How often should the MQ-138 sensor be calibrated? A: The sensor should be calibrated periodically, depending on the usage and the environmental conditions.
Q: Can the MQ-138 sensor detect other gases? A: While the sensor is designed for formaldehyde, it may respond to other gases. It is important to use the sensor in an environment where the target gas is the primary concern.
Q: Is the MQ-138 sensor suitable for outdoor use? A: The sensor is designed for indoor use and may not perform reliably outdoors due to environmental factors.
// MQ-138 Formaldehyde Sensor Example Code
int analogPin = A0; // Analog input pin connected to AOUT on the sensor
int sensorValue = 0; // Variable to store the sensor value
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
}
void loop() {
sensorValue = analogRead(analogPin); // Read the sensor value
Serial.print("Formaldehyde concentration: ");
Serial.println(sensorValue); // Print the sensor value to the serial monitor
delay(1000); // Wait for 1 second before reading again
}
Note: This example code provides a simple way to read the analog output from the MQ-138 sensor. The raw sensor value needs to be converted to an actual concentration value using a calibration curve specific to the MQ-138 sensor. Calibration involves comparing the sensor's output to known formaldehyde concentrations under controlled conditions.