upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the TA12-200 Current Transformer. More...

Detailed Description

UPM module for the TA12-200 current transformer found, for instance, in the Grove Electricity Sensor. This module can measure AC moving through a wire at up to 5 A.

ta12200.jpg
// Instantiate a TA12-200 sensor on analog pin A0
upm::TA12200 electricity(0);
while (shouldRun) {
unsigned int maxVal = electricity.highestValue();
float current = electricity.milliAmps(maxVal);
cout << "Max ADC Value: " << maxVal << ", current: " << current << "mA" << endl;
upm_delay_us(100000);
}

Public Member Functions

 TA12200 (int pin)
 
 ~TA12200 ()
 
uint32_t getMillis ()
 
void initClock ()
 
int highestValue ()
 
float milliAmps (unsigned int val, int res=TA12200_ADC_RES)
 

Constructor & Destructor Documentation

TA12200 ( int  pin)

TA12200 constructor

Parameters
pinAnalog pin to use
~TA12200 ( )

TA12200 destructor

Member Function Documentation

uint32_t getMillis ( )

Returns the number of milliseconds elapsed since initClock() was last called.

Returns
Elapsed milliseconds
void initClock ( )

Resets the clock

int highestValue ( )

Gets the conversion value from the sensor

Returns
Highest value obtained over 1 second of measuring or -1 if error
float milliAmps ( unsigned int  val,
int  res = TA12200_ADC_RES 
)

Computes the measured voltage

Parameters
valValue measured by highestValue()
resADC resolution
Returns
Measured current in mA

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