1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/drivers/include/mq3.h

82 lines
1.9 KiB
C
Raw Normal View History

/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/
/**
2017-08-29 18:00:46 +02:00
* @defgroup drivers_mq3 MQ-3 Alcohol Tester
* @ingroup drivers_sensors
* @brief Device driver for the MQ-3 alcohol sensor
* @{
*
* @file
* @brief Device driver interface for the MQ-3 alcohol sensor
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef MQ3_H
#define MQ3_H
#include "periph/adc.h"
2014-10-31 12:30:03 +01:00
#ifdef __cplusplus
extern "C" {
#endif
2017-03-06 17:43:56 +01:00
/**
2017-08-29 18:00:46 +02:00
* @brief maximum unprocessed value fetched form the sensor
2017-03-06 17:43:56 +01:00
*/
#define MQ3_MAX_RAW_VALUE (1023U)
/**
2017-08-29 18:00:46 +02:00
* @brief device descriptor for a MQ-3 sensor
*/
typedef struct {
adc_t adc_line; /**< the used ADC line */
} mq3_t;
/**
2017-08-29 18:00:46 +02:00
* @brief 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.
*
* @param[out] dev device descriptor of an MQ-3 sensor
2017-03-06 17:43:56 +01:00
* @param[in] adc_line the ADC device the sensor is connected to
*
2023-05-31 20:05:11 +02:00
* @retval 0 success
* @retval -1 failure
*/
int mq3_init(mq3_t *dev, adc_t adc_line);
/**
2017-08-29 18:00:46 +02:00
* @brief Read the RAW sensor value, can be between 0 and MQ3_MAX_RAW_VALUE
*
* @param[in] dev device descriptor of the MQ-3 sensor to read from
*
* @return the raw sensor value, between 0 and MQ3_MAX_RAW_VALUE
*/
2023-05-31 20:05:11 +02:00
int16_t mq3_read_raw(const mq3_t *dev);
/**
2017-08-29 18:00:46 +02:00
* @brief Read the scaled sensor value of PPM of alcohol
*
* @param[in] dev device descriptor of the MQ-3 sensor to read from
*
* @return the scaled sensor value in PPM of alcohol
*/
2023-05-31 20:05:11 +02:00
int16_t mq3_read(const mq3_t *dev);
2014-10-31 12:30:03 +01:00
#ifdef __cplusplus
}
#endif
#endif /* MQ3_H */
/** @} */