Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Mega 2560 Based Multi-Gas Detection System with ADS1115 ADC

Image of Arduino Mega 2560 Based Multi-Gas Detection System with ADS1115 ADC

Circuit Documentation

Summary

The circuit in question is designed to monitor environmental conditions using a series of gas sensors interfaced with an Arduino Mega 2560 microcontroller and an Adafruit ADS1115 16-bit I2C ADC (Analog-to-Digital Converter). The gas sensors included are the MQ-2, MQ-3, MQ-7, and MQ-135, each capable of detecting different types of gases. The ADC is used to convert the analog signals from the gas sensors into digital values that the Arduino can process. The power supply provides the necessary voltage to the components. The circuit utilizes I2C communication between the Arduino and the ADC, and analog inputs to read the sensors' data.

Component List

  • Arduino Mega 2560: A microcontroller board based on the ATmega2560, with numerous digital and analog I/O pins.
  • Adafruit ADS1115 16Bit I2C ADC: A precision analog-to-digital converter with I2C interface, used for reading analog signals.
  • MQ-2 Gas Sensor: A sensor for detecting LPG, propane, hydrogen, and other combustible gases.
  • MQ-3 Alcohol Sensor: A sensor for detecting alcohol vapor in the air.
  • MQ-135 Air Quality Sensor: A sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke, and CO2.
  • MQ-7 Carbon Monoxide Sensor: A sensor for detecting carbon monoxide gas concentrations in the air.
  • POWER SUPPLY 5V 5AMP: A power supply unit that converts 220V AC to 5V DC, providing power to the circuit.

Wiring Details

Arduino Mega 2560

  • VIN: Connected to the VCC of MQ-2, MQ-3, MQ-7, MQ-135, and VDD of ADS1115.
  • GND: Common ground with MQ-2, MQ-3, MQ-7, MQ-135, and GND of ADS1115.
  • D21/SCL: Connected to the SCL pin of the ADS1115 for I2C communication.
  • D20/SDA: Connected to the SDA pin of the ADS1115 for I2C communication.

Adafruit ADS1115 16Bit I2C ADC

  • VDD: Connected to the VIN of the Arduino Mega 2560.
  • GND: Common ground with the Arduino Mega 2560.
  • SCL: Connected to the D21/SCL of the Arduino Mega 2560.
  • SDA: Connected to the D20/SDA of the Arduino Mega 2560.
  • AIN0: Connected to the AO pin of MQ-2.
  • AIN1: Connected to the AO pin of MQ-3.
  • AIN2: Connected to the AO pin of MQ-7.
  • AIN3: Connected to the AO pin of MQ-135.

MQ-2 Gas Sensor

  • Vcc: Connected to the VIN of the Arduino Mega 2560.
  • GND: Common ground with the Arduino Mega 2560.
  • AO: Connected to the AIN0 of the ADS1115.

MQ-3 Alcohol Sensor

  • VCC: Connected to the VIN of the Arduino Mega 2560.
  • GND: Common ground with the Arduino Mega 2560.
  • AO: Connected to the AIN1 of the ADS1115.

MQ-135 Air Quality Sensor

  • VCC: Connected to the VIN of the Arduino Mega 2560.
  • GND: Common ground with the Arduino Mega 2560.
  • A0: Connected to the AIN3 of the ADS1115.

MQ-7 Carbon Monoxide Sensor

  • VCC: Connected to the VIN of the Arduino Mega 2560.
  • GND: Common ground with the Arduino Mega 2560.
  • AO: Connected to the AIN2 of the ADS1115.

POWER SUPPLY 5V 5AMP

  • 220V Positive Pole (AC): Input from AC power source.
  • 220V Negative Pole (AC): Input from AC power source.
  • GND (DC): Common ground with the Arduino Mega 2560.
  • 12V-24V Output (DC): Not connected in this circuit.
  • GND: Common ground with the Arduino Mega 2560.

Documented Code

Arduino Mega 2560 Code

#include <Wire.h>
#include <Adafruit_ADS1X15.h>

// Create an ADS1115 object
Adafruit_ADS1115 ads;  // Use default constructor

void setup() {
  Serial.begin(9600);
  
  // Initialize the ADS1115 module
  if (!ads.begin(0x48)) {  // Pass the I2C address here
    Serial.println("Failed to initialize ADS1115.");
    while (1);
  }
  
  Serial.println("ADS1115 initialized.");
}

void loop() {
  // Read analog values from the MQ sensors
  int16_t adc0 = ads.readADC_SingleEnded(0);  // MQ-2 on A0
  int16_t adc1 = ads.readADC_SingleEnded(1);  // MQ-3 on A1
  int16_t adc2 = ads.readADC_SingleEnded(2);  // MQ-7 on A2
  int16_t adc3 = ads.readADC_SingleEnded(3);  // MQ-135 on A3
  
  // Convert ADC values to voltage (optional, for reference)
  float voltage0 = adc0 * 0.1875 / 1000;  // ADS1115 16-bit, ±6.144V range, 0.1875mV per bit
  float voltage1 = voltage0;  // Same for other channels
  float voltage2 = voltage0;
  float voltage3 = voltage0;

  // Print ADC values and voltage to the Serial Monitor
  Serial.print("MQ-2 (A0) ADC: "); Serial.print(adc0);
  Serial.print(", Voltage: "); Serial.print(voltage0); Serial.println(" V");

  Serial.print("MQ-3 (A1) ADC: "); Serial.print(adc1);
  Serial.print(", Voltage: "); Serial.print(voltage1); Serial.println(" V");

  Serial.print("MQ-7 (A2) ADC: "); Serial.print(adc2);
  Serial.print(", Voltage: "); Serial.print(voltage2); Serial.println(" V");

  Serial.print("MQ-135 (A3) ADC: "); Serial.print(adc3);
  Serial.print(", Voltage: "); Serial.print(voltage3); Serial.println(" V");

  // Add delay for readability
  delay(1000);
}

This code initializes the ADS1115 ADC and reads the analog values from the MQ series gas sensors. It then prints the raw ADC values and the corresponding voltages to the Serial Monitor. The I2C address of the ADS1115 is set to 0x48, which is the default when the ADDR pin is connected to GND. The code includes a delay for readability of the output.