Sentinel
Loading...
Searching...
No Matches
MQ2Sensor Class Reference

Class for the MQ-2 gas sensor. More...

#include <mq2.h>

Public Member Functions

 MQ2Sensor (uint8_t pin, const char *board="ESP-32", float voltageResolution=3.3, uint8_t adcBitResolution=12, const char *type="MQ-2")
 Construct a new MQ2Sensor object.
 
void update ()
 Updates the MQ2 sensor.
 
int getValue ()
 Gets the value from the MQ2 sensor.
 
void begin ()
 Initializes the MQ2 sensor.
 
void calibrate ()
 Calibrates the MQ2 sensor.
 

Detailed Description

Class for the MQ-2 gas sensor.

Constructor & Destructor Documentation

◆ MQ2Sensor()

MQ2Sensor::MQ2Sensor ( uint8_t pin,
const char * board = "ESP-32",
float voltageResolution = 3.3,
uint8_t adcBitResolution = 12,
const char * type = "MQ-2" )

Construct a new MQ2Sensor object.

Parameters
pinPin number for the sensor
boardBoard type (default is "ESP-32")
voltageResolutionVoltage resolution (default is 3.3)
adcBitResolutionADC bit resolution (default is 12)
typeSensor type (default is "MQ-2")

Member Function Documentation

◆ begin()

void MQ2Sensor::begin ( )

Initializes the MQ2 sensor.

Initializes the MQ2 sensor with the given parameters.

◆ calibrate()

void MQ2Sensor::calibrate ( )

Calibrates the MQ2 sensor.

Calibrates the MQ2 sensor by averaging 10 readings in clean air.

◆ getValue()

int MQ2Sensor::getValue ( )

Gets the value from the MQ2 sensor.

Returns the value from the MQ2 sensor.

◆ update()

void MQ2Sensor::update ( )

Updates the MQ2 sensor.

Updates the MQ2 sensor with the latest readings.


The documentation for this class was generated from the following files: