The MQ-137 is an analog gas sensor module used for the detection of ammonia (NH3) in the air. It is a widely used sensor in various applications such as environmental monitoring, agricultural, industrial processes, and safety systems where the presence of ammonia needs to be detected and measured.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (5V) |
2 | GND | Ground |
3 | DO | Digital output (TTL) |
4 | AO | Analog output |
// MQ-137 Ammonia Gas Sensor Example Code
const int analogPin = A0; // Analog input pin connected to AO pin of the sensor
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
}
void loop() {
int sensorValue = analogRead(analogPin); // Read the analog value from sensor
float concentration = sensorValue * (10.0 / 1023.0); // Convert to concentration
// Note: The conversion factor will vary depending on calibration
Serial.print("Ammonia Concentration: ");
Serial.print(concentration);
Serial.println(" ppm");
delay(1000); // Wait for a second before reading again
}
Note: The above code is a simple example to read the analog value from the MQ-137 sensor. The conversion from the analog value to the actual concentration in ppm requires calibration with a known ammonia concentration. The 10.0 / 1023.0
factor is an example and should be replaced with the appropriate calibration factor for your specific setup.
Remember to keep code comments concise and within the 80 character line length limit.