upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

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 (true) {
long val = vDiv.value(100);
float gain3val = vDiv.computedValue(gain3, val);
float gain10val = vDiv.computedValue(gain10, val);
System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: "
+ gain10val);
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 GroveVDiv (int pin)
 
long value (long samples)
 
float computedValue (short gain, long val, int vref, int res)
 
float computedValue (short gain, long val, int vref)
 
float computedValue (short gain, long val)
 

Constructor & Destructor Documentation

GroveVDiv ( int  pin)

Grove Voltage Divider sensor constructor

Parameters
pinAnalog pin to use

Member Function Documentation

float computedValue ( short  gain,
long  val,
int  vref,
int  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
long value ( long  samples)

Gets the conversion value from the sensor

Parameters
samplesSpecifies how many samples to average over
Returns
Average ADC conversion value

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