The most basic connection for an MQ5 is between a digital pin on theArduino Unoand its power supply. You’ll need to connect a +5V line from the Arduino to pin 4 (the “VCC” connector) for power. And another GND line from the Arduino to pin 6 (the “GND” connector) for grounding. I have used both analogue and Digital Pins You can use either digital or analogue. To verify that your connection has been successful you’ll need both circuit diagrams and schematics.
MQ5 Arduino sensors can be used in different situations even though it may be hard to believe. For instance, to test if there is a gas leak when starting a car, you could use an MQ5 sensor. With the help of a cigarette lighter, pressure should rise as one presses the trigger and provides the needed gas leakage.
Codefloat sensor=A0;
float gas_value;
void setup(){
pinMode(sensor,INPUT);
Serial.begin(9600);
}
void loop(){
gas_value=analogRead(sensor);
Serial.println(gas_value);
}
In the Above section, we have written a very basic example of the analog read function of Arduino. Firstly we have declared 2 float variables Because the Gas values can be either in Decimals or in floats.
In Setup Function we have to Enable our serial monitor at 9600 Bauds we have different options for setting the serial monitor. By default, it comes with 9600 Bauds. I have kept it as it is. After that, we will Enable our sensor pin As analog Read Pin Attached to A0.
In the loop Function just have to read the Analog pin and Store it in our Pre Declared Variables. and print them in the Serial Monitor.
Comments