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

API for MCP9808 precision temprature sensor. More...

Detailed Description

The MCP9808 digital temperature sensor converts temperatures between -20°C and +100°C to a digital word with ±0.5°C (max.) accuracy. The MCP9808 comes with user-programmable registers that provide flexibility for temperature sensing applications. The registers allow user-selectable settings such as Shutdown or low-power modes and the specification of temperature Event and Critical output boundaries. When the temperature changes beyond the specified boundary limits, the MCP9808 outputs an Event signal. The user has the option of setting the event output signal polarity as an active-low or active-high comparator output for thermostat operation, or as temperature event interrupt output for microprocessor-based systems. The event output can also be configured as a Critical temperature output.

Tested with Adafriut MCP9808 board.

mcp9808.jpg

Classes

class  MCP9808_CONFIG
 
class  MCP9808_REG
 
class  MCP9808_RESOLUTION
 

Public Member Functions

synchronized void delete ()
 
 MCP9808 (int bus, short address)
 
 MCP9808 (int bus)
 
String name ()
 
float getTemp ()
 
void shutDown (boolean sleep)
 
void shutDown ()
 
void setMode (boolean celsius)
 
void setMode ()
 
boolean isCelsius ()
 
boolean isTcrit ()
 
boolean isTupper ()
 
boolean isTlower ()
 
void setMonitorReg (MCP9808.MCP9808_REG reg, float value)
 
float getMonitorReg (MCP9808.MCP9808_REG reg)
 
void clearInterrupt ()
 
void setAlertMode (int command)
 
void clearAlertMode ()
 
void setHysteresis (MCP9808.MCP9808_CONFIG value)
 
float getHysteresis ()
 
void setResolution (MCP9808.MCP9808_RESOLUTION value)
 
float getResolution ()
 
int getManufacturer ()
 
int getDevicedId ()
 

Constructor & Destructor Documentation

MCP9808 ( int  bus,
short  address 
)

MCP9808 constructor

Parameters
busi2c bus the sensor is attached to.
address.Device address. Default is 0x18.

Member Function Documentation

int getDevicedId ( )

Returns device ID and revision. Typically 0x0400 With ID in the High byte.

float getHysteresis ( )

Returns hysteresis setting as a float value.

int getManufacturer ( )

Returns Manufacturer ID. Typically 0x0054;

float getMonitorReg ( MCP9808.MCP9808_REG  reg)

Returns the current value of TCrit, TUpper, TLower registers.

Parameters
reg- MCP9808_REG enum UPPER_TEMP, LOWER_TEMP or CRIT_TEMP.
float getResolution ( )

Returns float value representing the current resolution setting.

boolean isTcrit ( )

Returns true if TCrit threshold has been crossed Reflects the state of the bit based on the most recent readTemp() operation.

boolean isTlower ( )

Returns true if TLower threshold crossed. Reflects the state of the bit based on the most recent readTemp() operation.

boolean isTupper ( )

Returns true if TUpper threshold crossed Reflects the state of the bit based on the most recent readTemp() operation.

String name ( )

Returns the name of the sensor

void setAlertMode ( int  command)

Sets alert mode. Can use values from MCP9808_CONFIG enum. Values can be combined.

Parameters
command- a combination of options to set desired alert mode. See spcec sheet.
void setHysteresis ( MCP9808.MCP9808_CONFIG  value)

Sets hysteresis value.

Parameters
MCP9808_CONFIGenum value HYST_0, HYST_1_5, HYST_3_0 or HYST_6_0
void setMode ( boolean  celsius)

setMode - sets temperature reporting mode.

Parameters
celsius.Default is true. If false all temps will be reported in fahrenhiet.
void setMonitorReg ( MCP9808.MCP9808_REG  reg,
float  value 
)

Sets the value of TCrit, TUpper,TLower registers.

reg - MCP9808_REG enum UPPER_TEMP, LOWER_TEMP or CRIT_TEMP.

Parameters
value- float value representing the set value
void setResolution ( MCP9808.MCP9808_RESOLUTION  value)

Sets resolution of temperature conversion.

Parameters
value- MCP9808_RESOLUTION enum value. RES_LOW = +0.5 C RES_MEDIUM = +0.25 C RES_HIGH = +0.125 C RES_PRECISION = +0.0625 C (default).
void shutDown ( boolean  sleep)

Will cause the devices to either sleep or wakeup.

Parameters
sleep. Bool, default true to sleep. false to wake.

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