MQ Gas Sensors – Measuring gas
When you have initialized the sensor (either Qwiic or Native), we can read the sensor measurements in the loop() function:
void loop()
{
mq131.update(); // Update data, read voltage level from sensor
Serial.println("O3: " + String(mq131.readSensor())+"ppb"); // Print the readings to the serial monitor
delay(500); // Sampling frequency
}

Sensor reading on serial monitor
mq131.update()
Updates the data and reads the sensor's voltage
Returns value: None
mq131.readSensor()
Calculates gas concentration via the regression method and returns it
Returns value: Float value, gas concentration in ppm, ppb or mg/L, depending on the sensor
Full example
MQ-131-Qwiic.ino
Gas measurement example for the Qwiic version of MQ131 sensor
ℹ️
While this example covered the MQ131, the process is practically identical for every sensor, Qwiic and Native. We encourage you to check out all the examples here