sensor-experiments

Introduction

This experiment demonstrates how to use the MQ-4 sensor to detect methane gas in the environment.

Components Needed

No Ads Available.

Circuit Setup

  1. Connect the MQ-4 sensor to the Arduino (VCC, GND, and analog output pin).

The MQ-4 sensor detects methane gas and outputs a voltage proportional to the concentration of the gas.

Code for Methane Detection

Upload the following code to your Arduino to measure methane gas levels:


const int mq4Pin = A0;
int sensorValue;

void setup() {
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(mq4Pin);
  Serial.print("Methane Concentration: ");
  Serial.println(sensorValue);
  delay(1000);
}
            

Explanation

The MQ-4 sensor reacts to methane gas, producing an analog voltage proportional to the gas concentration. The Arduino reads this value and displays it on the serial monitor.

Troubleshooting

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!