upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Data Structures | Functions | Typedefs
mqx.h File Reference
Include dependency graph for mqx.h:

API Description

The mqx gas sensor driver can be used to read a wide range of sensors. The list below shows the currently supported sensors:

 mq2: H2/LPG/CH4/CO/alcohol/smoke/propane/etc
     LPG/propane 200-5000 ppm
     butane 300-5000 ppm
     CH4 5000-2000 ppm
     H2 300-5000 ppm
     alcohol 100-2000 ppm
 mq3: Alcohol/benzine/CH4/hexane/LPG/CO .05-10 mg/L
 mq4: CNG (mostly methane) 200-10000 ppm
 mq5: H2/LPG/CH4/CO/alcohol 200-10000 ppm
 mq6: LPG (mostly propane/butane) 200-10000 ppm
 mq7: CO 20-2000 ppm
 mq8: H 100-10000 ppm
 mq9: CO/CH4/LPG 200-1000/10000/10000 ppm

Go to the source code of this file.

Data Structures

struct  _mqx_context
 

Functions

mqx_context mqx_init (int16_t pin)
 
void mqx_close (mqx_context dev)
 
upm_result_t mqx_set_aref (const mqx_context dev, float aref)
 
upm_result_t mqx_set_scale (const mqx_context dev, float scale)
 
upm_result_t mqx_set_offset (const mqx_context dev, float offset)
 
float mqx_get_aref (const mqx_context dev)
 
float mqx_get_scale (const mqx_context dev)
 
float mqx_get_offset (const mqx_context dev)
 
upm_result_t mqx_get_normalized (const mqx_context dev, float *value)
 
upm_result_t mqx_get_raw_volts (const mqx_context dev, float *value)
 
upm_result_t mqx_get_volts (const mqx_context dev, float *value)
 

Typedefs

typedef struct _mqx_contextmqx_context
 

Function Documentation

mqx_context mqx_init ( int16_t  pin)

Initialize analog sensor

Parameters
pinAnalog pin
Returns
sensor context
void mqx_close ( mqx_context  dev)

Analog sensor destructor

Parameters
sensorcontext pointer
upm_result_t mqx_set_aref ( const mqx_context  dev,
float  aref 
)

Set ADC reference voltage

Parameters
devsensor context pointer
arefADC reference voltage
Returns
Function result code
upm_result_t mqx_set_scale ( const mqx_context  dev,
float  scale 
)

Set sensor scale. This scale is applied to the return value: counts = counts * scale

Parameters
devsensor context pointer
scalecount scale value used
Returns
Function result code
upm_result_t mqx_set_offset ( const mqx_context  dev,
float  offset 
)

Set sensor offset. This offset is applied to the return value: counts = counts + offset

Parameters
devsensor context pointer
offsetcount offset value used
Returns
Function result code
float mqx_get_aref ( const mqx_context  dev)

Get sensor aref

Parameters
devsensor context pointer
Returns
Sensor ADC reference voltage
float mqx_get_scale ( const mqx_context  dev)

Get sensor scale

Parameters
devsensor context pointer
Returns
Sensor scale
float mqx_get_offset ( const mqx_context  dev)

Get sensor offset

Parameters
devsensor context pointer
Returns
Sensor offset
upm_result_t mqx_get_normalized ( const mqx_context  dev,
float *  value 
)

Read normalized value for sensor

Parameters
devsensor context pointer
*valueNormalized value (0.0 -> 1.0)
Returns
Function result code
upm_result_t mqx_get_raw_volts ( const mqx_context  dev,
float *  value 
)

Read raw voltage from the sensor

Parameters
devsensor context pointer
*valueRaw sensor voltage
Returns
Function result code
upm_result_t mqx_get_volts ( const mqx_context  dev,
float *  value 
)

Read scaled/offset voltage from the sensor

Parameters
devsensor context pointer
*valueAdjusted sensor voltage
Returns
Function result code

Typedef Documentation

typedef struct _mqx_context * mqx_context

driver context