MQ-3 Alcohol Tester

Device driver for the MQ-3 alcohol sensor.

int mq3_init(mq3_t * dev, adc.h::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

dev:device descriptor of an MQ-3 sensor
adc_line:the ADC device the sensor is connected to

Return values

  • 0 on success
  • -1 on error
int mq3_read_raw(const mq3_t * dev)

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

Parameters

dev:device descriptor of the MQ-3 sensor to read from

Return values

  • the raw sensor value, between 0 and MQ3_MAX_RAW_VALUE
int mq3_read(const mq3_t * dev)

Read the scaled sensor value of PPM of alcohol.

Parameters

dev:device descriptor of the MQ-3 sensor to read from

Return values

  • the scaled sensor value in PPM of alcohol
MQ3_MAX_RAW_VALUE

maximum unprocessed value fetched form the sensor

1
(1023U)
struct mq3_t

device descriptor for a MQ-3 sensor

adc.h::adc_t adc_line

the used ADC line