GP2Y10xx Optical Dust Sensor device driver

GP2Y10xx Optical Dust Sensor Converter device driver. More...

Detailed Description

GP2Y10xx Optical Dust Sensor Converter device driver.

This driver works with GP2Y1010AU0F and GP2Y1014AU0F versions.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.

Usage

USEMODULE += gp2y10xx

The device can be initialized with gp2y10xx_init and gp2y10xx_read_density is used to read the current dust density that the sensor can detect.

Modules

 GP2Y10xx driver compile configurations
 

Files

file  gp2y10xx_params.h
 Default configuration for GP2Y10xx devices.
 
file  gp2y10xx.h
 GP2Y10xx device driver.
 

Data Structures

struct  gp2y10xx_params_t
 GP2Y10xx device parameters. More...
 
struct  gp2y10xx_t
 GP2Y10xx device descriptor. More...
 

Macros

#define CONFIG_GP2Y10XX_MAX_READINGS   (10)
 This configures the maximum number of ADC readings stored to calculate the average ADC value. More...
 

Enumerations

enum  { GP2Y10XX_OK = 0, GP2Y10XX_ERR_ADC = -1, GP2Y10XX_ERR_ILED = -2 }
 Driver error values. More...
 
enum  gp2y10xx_level_t { GP2Y10XX_ILED_LEVEL_HIGH, GP2Y10XX_ILED_LEVEL_LOW }
 ILED pin level. More...
 

Functions

int gp2y10xx_init (gp2y10xx_t *dev, const gp2y10xx_params_t *params)
 Initialize an GP2Y10xx device. More...
 
int gp2y10xx_read_density (const gp2y10xx_t *dev, uint16_t *density)
 Read a raw ADC value. More...
 

Macro Definition Documentation

◆ CONFIG_GP2Y10XX_MAX_READINGS

#define CONFIG_GP2Y10XX_MAX_READINGS   (10)

This configures the maximum number of ADC readings stored to calculate the average ADC value.

The bigger the number of readings the bigger each device descriptor will be.

Definition at line 57 of file gp2y10xx.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Driver error values.

Enumerator
GP2Y10XX_OK 

Everything is ok.

GP2Y10XX_ERR_ADC 

ADC error.

GP2Y10XX_ERR_ILED 

ILED pin error.

Definition at line 63 of file gp2y10xx.h.

◆ gp2y10xx_level_t

ILED pin level.

This specifies how the ILED pin behaves, if it's on when it's active-low/high. Waveshare breakout board is active-high, that is, that the voltage is 3.3v to turn ILED on (logic 1) and 0v to turn it off (logic 0).

Enumerator
GP2Y10XX_ILED_LEVEL_HIGH 

Active high.

GP2Y10XX_ILED_LEVEL_LOW 

Active low.

Definition at line 76 of file gp2y10xx.h.

Function Documentation

◆ gp2y10xx_init()

int gp2y10xx_init ( gp2y10xx_t dev,
const gp2y10xx_params_t params 
)

Initialize an GP2Y10xx device.

Parameters
[in,out]devDevice descriptor.
[in]paramsDevice configuration.
Returns
GP2Y10XX_OK on successful initialization.
GP2Y10XX_ERR_ADC if ADC line initialization failed.
GP2Y10XX_ERR_ILED if the ILED pin initialization failed.

◆ gp2y10xx_read_density()

int gp2y10xx_read_density ( const gp2y10xx_t dev,
uint16_t *  density 
)

Read a raw ADC value.

Parameters
[in]devDevice descriptor.
[out]densityDust density value in ug/m3.
Returns
GP2Y10XX_OK on successful read.
Any other value on error.