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

API for the AM2315 Temperature & Humidity Sensor. More...

Detailed Description

AM2315 by Measurement Specialties (http://www.aosong.com/asp_bin/Products/en/AM2315.pdf) is a digital humidity sensor with temperature output. RH reports between 0 and 100%, and the temperature range is -40 to +125 degC. The sampling period of this sensor is 2 seconds. Reads occurring more often than that return cached data.

am2315.jpeg
float humidity = 0.0;
float temperature = 0.0;
sensor = new upm::AM2315(0, AM2315_I2C_ADDRESS);
sensor->testSensor();
while (!doWork) {
humidity = sensor->getHumidity();
temperature = sensor->getTemperature();
std::cout << "humidity value = " <<
humidity <<
", temperature value = " <<
temperature << std::endl;
usleep (500000);
}

Public Member Functions

 AM2315 (int bus, int devAddr=AM2315_I2C_ADDRESS)
 
 ~AM2315 ()
 
float getHumidity (void)
 
float getTemperature (void)
 
float getTemperatureF (void)
 
int testSensor (void)
 
int i2cWriteReg_32 (int reg, uint32_t ival)
 
int i2cWriteReg_16 (int reg, uint16_t ival)
 
int i2cWriteReg_8 (int reg, uint8_t ival)
 
uint32_t i2cReadReg_32 (int reg)
 
uint16_t i2cReadReg_16 (int reg)
 
uint8_t i2cReadReg_8 (int reg)
 

Constructor & Destructor Documentation

AM2315 ( int  bus,
int  devAddr = AM2315_I2C_ADDRESS 
)

Instantiates an AM2315 object

Parameters
busNumber of the used bus
devAddrAddress of the used I2C device
modeAM2315 oversampling

Here is the call graph for this function:

~AM2315 ( )

AM2315 object destructor; basically, it closes the I2C connection.

Member Function Documentation

float getHumidity ( void  )

Gets the current measured humidity [RH]

Data is updated every 2 seconds - accesses occurring more often than that return cached data

Here is the caller graph for this function:

float getTemperature ( void  )

Gets the humidity cell temperature [degC]

Data is updated every 2 seconds - accesses occurring more often than that return cached data

Here is the caller graph for this function:

float getTemperatureF ( void  )

Gets the humidity cell temperature [degF]

Data is updated every 2 seconds - accesses occurring more often than that return cached data

Here is the call graph for this function:

int testSensor ( void  )

Function intended to test the device and verify it is operating correctly.

Here is the call graph for this function:

int i2cWriteReg_32 ( int  reg,
uint32_t  ival 
)

Writes a four-byte (32b) register

Note: these access routines are not the normal accesses to an I2C device. AM2315 contains a microcontroller that manages the actual readings. These handlers then make requests over I2C using a protocol defined by AM2315.

Parameters
regAddress of the register
ival32b value
int i2cWriteReg_16 ( int  reg,
uint16_t  ival 
)

Writes a two-byte (16b) register

Parameters
regAddress of the register
ival16b value
int i2cWriteReg_8 ( int  reg,
uint8_t  ival 
)

Writes a one-byte (8b) register

Parameters
regAddress of the register
ival8b value
uint32_t i2cReadReg_32 ( int  reg)

Reads a four-byte register

Parameters
regAddress of the register

Here is the caller graph for this function:

uint16_t i2cReadReg_16 ( int  reg)

Reads a two-byte register

Parameters
regAddress of the register

Here is the caller graph for this function:

uint8_t i2cReadReg_8 ( int  reg)

Reads a one-byte register

Parameters
regAddress of the register

Here is the caller graph for this function:


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