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
TA12200 Class Reference

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 = new upm::TA12200(0);
while (shouldRun)
{
unsigned int maxVal = electricity->highestValue();
float current = electricity->milliAmps(maxVal);
cout << "Max ADC Value: " << maxVal << ", current: " << current
<< "mA" << endl;
usleep(100000);
}

Public Member Functions

 TA12200 (int pin)
 
 ~TA12200 ()
 
uint32_t getMillis ()
 
void initClock ()
 
unsigned 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

unsigned int highestValue ( )

Gets the conversion value from the sensor

Returns
Highest value obtained over 1 second of measuring
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: