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. More...
 
int mq3_read_raw (const mq3_t *dev)
 Read the RAW sensor value, can be between 0 and MQ3_MAX_RAW_VALUE. More...
 
int mq3_read (const mq3_t *dev)
 Read the scaled sensor value of PPM of alcohol. More...
 

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
Returns
0 on success
-1 on error

◆ mq3_read()

int 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()

int 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