upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
GroveVDiv Class Reference

API for the Grove Voltage Divider Sensor. More...

Detailed Description

UPM module for the Grove Voltage Divider sensor

grovevdiv.jpg
// Instantiate a Grove Voltage Divider sensor on analog pin A0
// collect data and output measured voltage according to the setting
// of the scaling switch (3 or 10)
while (shouldRun)
{
unsigned int val = vDiv->value(100);
float gain3val = vDiv->computedValue(3, val);
float gain10val = vDiv->computedValue(10, val);
cout << "ADC value: " << val << " Gain 3: " << gain3val
<< "v Gain 10: " << gain10val << "v" << endl;
sleep(1);
}

Public Member Functions

 GroveVDiv (int pin)
 
 ~GroveVDiv ()
 
unsigned int value (unsigned int samples)
 
float computedValue (uint8_t gain, unsigned int val, int vref=GROVEVDIV_VREF, int res=GROVEVDIV_ADC_RES)
 

Constructor & Destructor Documentation

GroveVDiv ( int  pin)

Grove Voltage Divider sensor constructor

Parameters
pinAnalog pin to use
~GroveVDiv ( )

Grove Voltage Divider destructor

Member Function Documentation

unsigned int value ( unsigned int  samples)

Gets the conversion value from the sensor

Parameters
samplesSpecifies how many samples to average over
Returns
Average ADC conversion value
float computedValue ( uint8_t  gain,
unsigned int  val,
int  vref = GROVEVDIV_VREF,
int  res = GROVEVDIV_ADC_RES 
)

Computes the measured voltage

Parameters
gainGain switch, either 3 or 10 for Grove
valMeasured voltage (from value())
vrefReference voltage in millivolts
resADC resolution
Returns
Measured voltage

The documentation for this class was generated from the following files: