#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Define the analog input pins for ESP32
const int mq7Pin = 35; // GPIO34
const int mq6Pin = 2;
// GPIO35
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// Start the serial communication
Serial.begin(115200);
// Initialize the LCD
lcd.init();
lcd.backlight();
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print("MQ7 & MQ6 Sensor");
delay(2000);
}
void loop() {
// Read the analog values from the sensors
int mq7Value = analogRead(mq7Pin);
int mq6Value = analogRead(mq6Pin);
// Print the sensor values to the Serial Monitor
Serial.print("MQ-7 Value: ");
Serial.print(mq7Value);
Serial.print("\t MQ-6 Value: ");
Serial.println(mq6Value);
// Display sensor values on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("MQ-7: ");
lcd.print(mq7Value);
lcd.setCursor(0, 1);
lcd.print("MQ-6: ");
lcd.print(mq6Value);
// Wait for a while before reading the values again
delay(1000);
}