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

UPM API for the T3311 MODBUS Temperature and Humidity Sensor. More...

Detailed Description

This module implements support for the Comet System T3311 Temperature and Humidity transmitter. It uses MODBUS over an RS232 serial port. You must have libmodbus v3.1.2 (or greater) installed to compile and use this driver.

This module was developed using libmodbus 3.1.2, and T3311 Firmware revison 2.66 connected via a Prolific RS232 Serial to USB adaptor. You cannot use the built in TTL UART pins for accessing this device – you must use a full serial RS232 interface connected via USB.

string defaultDev = "/dev/ttyUSB0";
// if an argument was specified, use it as the device instead
if (argc > 1)
defaultDev = string(argv[1]);
cout << "Initializing..." << endl;
// Instantiate an T3311 instance, using MODBUS slave address 1, and
// default comm parameters (9600, 8, N, 2)
upm::T3311 sensor(defaultDev, 1);
// output the serial number and firmware revision
cout << "Serial Number: " << sensor.getSerialNumber() << endl;
cout << "Firmware Revision: " << sensor.getFirmwareMajor() << "." << sensor.getFirmwareMinor()
<< endl;
cout << endl;
// update and print available values every second
while (shouldRun) {
// update our values from the sensor
sensor.update();
// we show both C and F for temperature
cout << "Temperature: " << sensor.getTemperature() << " C / " << sensor.getTemperature(true)
<< " F" << endl;
cout << "Humidity: " << sensor.getHumidity() << " %" << endl;
// this value depends on the sensor configuration -- by default
// it is the dew point temperature
cout << "Computed Value: " << sensor.getComputedValue() << endl;
// with FW revisions > 2.44, extended computed data is available
if (sensor.extendedDataAvailable()) {
cout << "Dew Point Temperature: " << sensor.getDewPointTemperature() << " C / "
<< sensor.getDewPointTemperature(true) << " F" << endl;
cout << "Absolute Humidity: " << sensor.getAbsoluteHumidity() << " g/m3" << endl;
cout << "Specific Humidity: " << sensor.getSpecificHumidity() << " g/kg" << endl;
cout << "Mixing Ratio: " << sensor.getMixingRatio() << " g/kg" << endl;
cout << "Specific Enthalpy: " << sensor.getSpecificEnthalpy() << " kJ/kg" << endl;
}
cout << endl;
upm_delay(1);
}
cout << "Exiting..." << endl;

Public Types

enum  REGS_T {
  REG_TEMPERATURE = 0x0030, REG_HUMIDITY = 0x0031, REG_COMPUTED = 0x0032, REG_DEW_POINT = 0x0034,
  REG_ABS_HUMIDITY = 0x0035, REG_SPECIFIC_HUMIDITY = 0x0036, REG_MIXING_RATIO = 0x0037, REG_SPECIFIC_ENTHALPY = 0x0038,
  REG_SERIAL_HI = 0x1034, REG_SERIAL_LO = 0x1035, REG_UNIT_SETTINGS = 0x203F, REG_FW_HI = 0x3000,
  REG_FW_LO = 0x3001
}
 

Public Member Functions

 T3311 (std::string device, int address, int baud=9600, int bits=8, char parity='N', int stopBits=2)
 
 ~T3311 ()
 
bool extendedDataAvailable ()
 
void update ()
 
float getTemperature (bool fahrenheit=false)
 
float getHumidity ()
 
float getComputedValue ()
 
float getDewPointTemperature (bool fahrenheit=false)
 
float getAbsoluteHumidity ()
 
float getSpecificHumidity ()
 
float getMixingRatio ()
 
float getSpecificEnthalpy ()
 
std::string getSerialNumber ()
 
int getFirmwareMajor ()
 
int getFirmwareMinor ()
 
void setDebug (bool enable)
 

Protected Member Functions

uint16_t readInputReg (int reg)
 
int readInputRegs (int reg, int len, uint16_t *buf)
 

Protected Attributes

modbus_t * m_mbContext
 
bool m_isCelsius
 
bool m_isExtendedDataAvailable
 
int m_fwRevHi
 
int m_fwRevLo
 
std::string m_serialNumber
 

Constructor & Destructor Documentation

T3311 ( std::string  device,
int  address,
int  baud = 9600,
int  bits = 8,
char  parity = 'N',
int  stopBits = 2 
)

T3311 constructor

Parameters
devicePath to the serial device
addressThe MODBUS slave address
baudThe baudrate of the device. Default: 9600
bitsThe number of bits per byte. Default: 8
parityThe parity of the connection, 'N' for None, 'E' for Even, 'O' for Odd. Default: 'N'
stopBitsThe number of stop bits. Default: 2

Here is the call graph for this function:

~T3311 ( )

T3311 Destructor

Member Function Documentation

bool extendedDataAvailable ( )
inline

Indicate whether the attached sensor supports extended Computed Data registers. Firmware versions at, or higher than 2.44 provide this data.

Returns
true if Extended Data is available, false otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

void update ( void  )

Read current values from the sensor and update internal stored values. This method must be called prior to querying any values, such as temperature or humidity.

Here is the call graph for this function:

Here is the caller graph for this function:

float getTemperature ( bool  fahrenheit = false)

Get the current temperature. update() must have been called prior to calling this method.

Parameters
fahrenheittrue to return the temperature in degrees fahrenheit, false to return the temperature in degrees celsius. The default is false (degrees Celsius).
Returns
The last temperature reading in Celsius or Fahrenheit

Here is the caller graph for this function:

float getHumidity ( void  )

Get the current relative humidity. update() must have been called prior to calling this method.

Returns
The last humidity reading

Here is the caller graph for this function:

float getComputedValue ( )

Get the current computed value. update() must have been called prior to calling this method. This value is configured via the configuration of the sensor using the sensors configuration utility, and can represent several different computed values. The default value from the factory is the current Dew Point Temperature.

Since the actual value configured is unknown (and unknowable) to this driver, the units represented depend on how you have configured the device. This function simply returns the value without any conversion or interpretation, other than the default scaling.

Returns
The last Computed Value

Here is the caller graph for this function:

float getDewPointTemperature ( bool  fahrenheit = false)

Get the current dew point temperature. update() must have been called prior to calling this method. This information is only available if the sensor supports Extended Data (ie: extendedDataAvailable() returns true).

Parameters
fahrenheittrue to return the temperature in degrees fahrenheit, false to return the temperature in degrees celsius. The default is false (degrees Celsius).
Returns
The last dew point temperature reading in Celsius or Fahrenheit

Here is the caller graph for this function:

float getAbsoluteHumidity ( )

Get the current absolute humidity. update() must have been called prior to calling this method. This information is only available if the sensor supports Extended Data (ie: extendedDataAvailable() returns true).

Returns
The last absolute humidity reading in g/m3 (grams per cubic meter).

Here is the caller graph for this function:

float getSpecificHumidity ( )

Get the current specific humidity. update() must have been called prior to calling this method. This information is only available if the sensor supports Extended Data (ie: extendedDataAvailable() returns true).

Returns
The last specific humidity reading in g/kg (grams per kilogram).

Here is the caller graph for this function:

float getMixingRatio ( )

Get the current mixing ratio. update() must have been called prior to calling this method. This information is only available if the sensor supports Extended Data (ie: extendedDataAvailable() returns true).

Returns
The last mixing ratio reading in g/kg (grams per kilogram).

Here is the caller graph for this function:

float getSpecificEnthalpy ( )

Get the current specific enthalopy, a measure of energy density. update() must have been called prior to calling this method. This information is only available if the sensor supports Extended Data (ie: extendedDataAvailable() returns true).

Returns
The last specific enthalopy reading in kJ/kg (kilojoules per kilogram).

Here is the caller graph for this function:

std::string getSerialNumber ( )
inline

Get the serial number of the sensor.

Returns
The serial number
int getFirmwareMajor ( )
inline

Get the firmware revision major number.

Returns
The firmware revsion major number.
int getFirmwareMinor ( )
inline

Get the firmware revision minor number.

Returns
The firmware revsion minor number.

Here is the call graph for this function:

void setDebug ( bool  enable)

Enable or disable debugging output. This primarily enables and disables libmodbus debugging output.

Parameters
enabletrue to enable debugging, false otherwise

Here is the caller graph for this function:


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