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

API Description

//Modified: Abhishek Malik <abhishek.malik@intel.com>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "gp2y0a.h"
#include "upm_utilities.h"
int main()
{
gp2y0a_context dev = gp2y0a_init(14, 5.0);
float val;
while(1){
if(gp2y0a_get_value(dev, 5.0, 20, &val) != UPM_SUCCESS){
printf("Failed to get any values from the sensor\n");
}
printf("Moisture Value: %f\n", val);
upm_delay(1);
}
return 0;
}

Go to the source code of this file.

Data Structures

struct  _gp2y0a_context
 

Functions

gp2y0a_context gp2y0a_init (int pin, float a_ref)
 
void gp2y0a_close (gp2y0a_context dev)
 
upm_result_t gp2y0a_get_value (gp2y0a_context dev, float a_ref, uint8_t samples, float *val)
 

Typedefs

typedef struct _gp2y0a_contextgp2y0a_context
 

Function Documentation

gp2y0a_context gp2y0a_init ( int  pin,
float  a_ref 
)

GP2Y0A sensor init function

Parameters
pinAnalog pin to use
a_refreference voltage
void gp2y0a_close ( gp2y0a_context  dev)

GP2Y0A close function

Parameters
devsensor struct
upm_result_t gp2y0a_get_value ( gp2y0a_context  dev,
float  a_ref,
uint8_t  samples,
float *  val 
)

Gets an average voltage value from the sensor

Parameters
devsensor struct
arefReference voltage in use (usually 5.0V or 3.3V)
samplesNumber of samples to average over
Returns
Average voltage reading

Typedef Documentation

typedef struct _gp2y0a_context * gp2y0a_context

device context