Loading...
Searching...
No Matches
MQ-3 Alcohol Tester

Device driver for the MQ-3 alcohol sensor. More...

Detailed Description

Device driver for the MQ-3 alcohol sensor.

Files

file  mq3.h
 Device driver interface for the MQ-3 alcohol sensor.
 

Data Structures

struct  mq3_t
 device descriptor for a MQ-3 sensor More...
 

Macros

#define MQ3_MAX_RAW_VALUE   (1023U)
 maximum unprocessed value fetched form the sensor
 

Functions

int mq3_init (mq3_t *dev, adc_t adc_line)
 Initialize a MQ-3 alcohol sensor.
 
int16_t mq3_read_raw (const mq3_t *dev)
 Read the RAW sensor value, can be between 0 and MQ3_MAX_RAW_VALUE.
 
int16_t mq3_read (const mq3_t *dev)
 Read the scaled sensor value of PPM of alcohol.
 

Macro Definition Documentation

◆ MQ3_MAX_RAW_VALUE

#define MQ3_MAX_RAW_VALUE   (1023U)

maximum unprocessed value fetched form the sensor

Definition at line 33 of file mq3.h.

Function Documentation

◆ mq3_init()

int mq3_init ( mq3_t dev,
adc_t  adc_line 
)

Initialize a MQ-3 alcohol sensor.

The MQ-3 sensor is interfaced by a single ADC pin, specified by adc and channel.

Note
The sensor needs about a minute to heat up before meaningful measurements can be made.
Parameters
[out]devdevice descriptor of an MQ-3 sensor
[in]adc_linethe ADC device the sensor is connected to
Return values
0success
-1failure

◆ mq3_read()

int16_t mq3_read ( const mq3_t dev)

Read the scaled sensor value of PPM of alcohol.

Parameters
[in]devdevice descriptor of the MQ-3 sensor to read from
Returns
the scaled sensor value in PPM of alcohol

◆ mq3_read_raw()

int16_t mq3_read_raw ( const mq3_t dev)

Read the RAW sensor value, can be between 0 and MQ3_MAX_RAW_VALUE.

Parameters
[in]devdevice descriptor of the MQ-3 sensor to read from
Returns
the raw sensor value, between 0 and MQ3_MAX_RAW_VALUE