// Code for MQ-3 sensor on XIAO ESP32 C3
#define MQ3_PIN 2 // GPIO2, Analog input A0 on XIAO ESP32 C3
void setup() {
Serial.begin(115200); // Start serial communication
pinMode(MQ3_PIN, INPUT); // Set the pin as input
}
void loop() {
int sensorValue = analogRead(MQ3_PIN); // Read the analog value
Serial.print("MQ-3 Sensor Value: ");
Serial.println(sensorValue); // Print the value to the Serial Monitor
delay(1000); // Wait for 1 second before reading again
}
Loading
xiao-esp32-c3
xiao-esp32-c3