Now let us examine the method of reading the analog output pin of the MQ2 gas sensor. The circuit connections for building a smoke detector prototype using its analog output pin is shown in figure 3. As shown in the figure, the MQ2 gas sensor to Arduino Uno connection, via its analog pin, is tabulated as follows:
Arduino Uno pin |
MQ2 gas sensor pin |
Analog I/O pin A5 |
A0 |
5V |
VCC |
GND |
GND |
Table 3: MQ2 gas sensor to Arduino - Analog connections
The remaining portions of the circuit, such as the Piezo Buzzer connection, will remain unaltered from the previous example with the digital pin. The Piezo Buzzer interfacing details are provided in the following table for reference.
Arduino Uno Pin |
Piezo Buzzer Pin |
Digital I/O pin 8 (via 100 Ohms) |
Positive terminal (longer leg) |
GND |
Negative terminal (shorter leg... |