This document provides a detailed overview of a simple circuit that interfaces an Arduino UNO with an MQ-3 Alcohol Sensor. The purpose of the circuit is to measure alcohol concentration levels and output the readings to a serial monitor. The Arduino UNO is used as the microcontroller to read analog values from the MQ-3 sensor and communicate the results. The circuit is powered by the Arduino UNO's 5V output, and the sensor's analog output is connected to one of the Arduino's analog input pins.
The following code is written for the Arduino UNO to interface with the MQ-3 Alcohol Sensor. The code initializes the sensor and serial communication, then continuously reads the analog value from the sensor and outputs it to the serial monitor.
/*
MQ-3 Alcohol Sensor Reading
This sketch interfaces with the MQ-3 alcohol sensor. It initializes the sensor
and serial communication, then continuously reads the analog value from the
sensor and outputs it to the serial monitor. The sensor requires a warm-up
period, which is handled in the setup function. Readings are taken every 2
seconds.
*/
#define MQ3pin A0 // Pin for the MQ-3 sensor's analog output
float sensorValue; // Variable to store sensor value
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
Serial.println("MQ3 warming up!");
delay(20000); // Warm-up time for the MQ3 sensor (20 seconds)
}
void loop() {
sensorValue = analogRead(MQ3pin); // Read from the MQ-3 sensor
// Print the sensor value to the serial monitor
Serial.print("Sensor Value: ");
Serial.println(sensorValue);
delay(2000); // Wait 2 seconds before next reading
}
The code includes a warm-up period for the sensor during the setup phase, after which it enters a loop where it reads the sensor value every 2 seconds and prints it to the serial monitor.