A driver object for the mcp9808 temperature sensor. More...
Public Member Functions | |
| def | __init__ (self, i2c, addr=0, Tup=0, Tlow=0, Tcrit=0, res=0x03, config=0x0000, debug=False) |
| Creates a mcp9808 object. More... | |
| def | conv_temp (self, Temp, from_unit, to_unit) |
| Converts a temperature to new units. More... | |
| def | temp_to_bytes (self, Temp) |
| Converts a temperature in celcius to a bytearry for the MCP9808 sensor. More... | |
| def | get_temp (self, unit='C') |
| Returns the curent ambient temperature measured by the sensor. More... | |
| def | upper_lim (self, Temp='GET', unit='C') |
| Sets or gets the curent upper temperature alert limit of the sensor. | |
| def | lower_lim (self, Temp='GET', unit='C') |
| Sets or gets the curent lower temperature alert limit of the sensor. More... | |
| def | crit_temp (self, Temp='GET', unit='C') |
| Sets or gets the curent critical temperature alert of the sensor. | |
| def | res (self, res='GET') |
| Gets or sets the device measurement resolution. More... | |
| def | get_mfgID (self) |
| Obtains the Manufacturer ID from the MCP9808 sensor. More... | |
| def | get_devID (self) |
| Obtains the Device ID and revision information from the MCP9808 sensor. More... | |
| def | config (self, act='GET', HYST=0x00, SHDN=False, CRIT_LOK=False, WIN_LOK=False, INT_CLR=False, ALERT_STAT=False, ALERT_CNT=False, ALERT_SEL=False, ALERT_POL=False, ALERT_MOD=False) |
| Allows reading and writing of the MCP9808 sensor config register. More... | |
| def | alert (self) |
| Returns the device alert state. | |
| def | celcius (self) |
| Returns the measured temperature in degrees Celcius. More... | |
| def | fahrenheit (self) |
| Returns the measured temperature in degrees Fahrenheit. More... | |
| def | check (self) |
| Checks to see if the device registers the correct Manufacturer ID (0x0054) More... | |
Public Attributes | |
| addr | |
| The I2C adress of the sensor. More... | |
| read_buf | |
| A byte array used to recieve data from the sensor. | |
| Tupper | |
| The upper temperature limit for alert in Celcius. | |
| Tlower | |
| The lower temperature limit for alert in Celcius. | |
| Tcritical | |
| The critical temperature for alert in Celcius. | |
| Tambinet | |
| The ambient temperature in Celcius. | |
| res | |
| The sensor resolution. More... | |
| config | |
| The sensor configuration data. More... | |
| mfg_id | |
| The manufacturer ID for the MCP9808 sensor. | |
| dev_id | |
| The device ID for the MCP9808 sensor. | |
| dev_rev | |
| The revision information for the MCP9808 sensor. | |
| alert | |
| Boolean indicating if the sensor is in alert. | |
| i2c | |
| The I2C object bound to the bus over which the sensor will communicate. | |
| debug | |
| A boolean that toggles the trace output to the command line. | |
Static Public Attributes | |
| int | R1_CONFIG = 1 |
| Configuration register. | |
| int | R2_UPPER_TEMP = 2 |
| Alert Temperature Upper Boundary Trip register. | |
| int | R3_LOWER_TEMP = 3 |
| Alert Temperature Upper Boundary Trip register. | |
| int | R4_CRIT_TEMP = 4 |
| Critical Temperature Trip register. | |
| int | R5_TEMPERATURE = 5 |
| Temperature register. | |
| int | R6_MFG_ID = 6 |
| Manufacturer ID register. | |
| int | R7_DEV_ID_AND_REV = 7 |
| Device ID/Revision register. | |
| int | R8_RESOLUTION = 8 |
| Resolution register. | |
A driver object for the mcp9808 temperature sensor.
| def mcp9808.MCP9808.__init__ | ( | self, | |
| i2c, | |||
addr = 0, |
|||
Tup = 0, |
|||
Tlow = 0, |
|||
Tcrit = 0, |
|||
res = 0x03, |
|||
config = 0x0000, |
|||
debug = False |
|||
| ) |
Creates a mcp9808 object.
This function creates a mcp 9808 object. Unless specified, all parameters are set to power on defaults.
| i2c | The I2C object bound to the bus over which the sensor will communicate. |
| addr | Interger specifying the user selectable portion of the sensor address (0-7) |
| Tup | The upper temperature limit for alert in Celcius |
| Tlow | The lower temperature limit for alert in Celcius |
| Tcrit | The critical temperature for alert in Celcius |
| res | The sensor resolution: an int from 0-3 selects from the following [+0.5, +0.25, +0.125, +0.0625] |
| config | The sensor configuration: config can be set quickly here, or in detail using the config method |
| debug | A boolean that toggles the trace output on or off. |
| def mcp9808.MCP9808.celcius | ( | self | ) |
Returns the measured temperature in degrees Celcius.
| def mcp9808.MCP9808.check | ( | self | ) |
Checks to see if the device registers the correct Manufacturer ID (0x0054)
| def mcp9808.MCP9808.config | ( | self, | |
act = 'GET', |
|||
HYST = 0x00, |
|||
SHDN = False, |
|||
CRIT_LOK = False, |
|||
WIN_LOK = False, |
|||
INT_CLR = False, |
|||
ALERT_STAT = False, |
|||
ALERT_CNT = False, |
|||
ALERT_SEL = False, |
|||
ALERT_POL = False, |
|||
ALERT_MOD = False |
|||
| ) |
Allows reading and writing of the MCP9808 sensor config register.
Method not complete...
| def mcp9808.MCP9808.conv_temp | ( | self, | |
| Temp, | |||
| from_unit, | |||
| to_unit | |||
| ) |
Converts a temperature to new units.
@details This function accepts a numerical temperature and two strings
specifying the old and new units. The function works for any
combination of the following units:
Celcius 'C' Fahrenheit 'F' Kelvin 'K' Rankine 'R'
@param Temp The temperature value to be converted. @param from_units A string specifying the original units. @param to_units A string specifying the new units. @return The converted temperature.
| def mcp9808.MCP9808.fahrenheit | ( | self | ) |
Returns the measured temperature in degrees Fahrenheit.
| def mcp9808.MCP9808.get_devID | ( | self | ) |
Obtains the Device ID and revision information from the MCP9808 sensor.
| def mcp9808.MCP9808.get_mfgID | ( | self | ) |
Obtains the Manufacturer ID from the MCP9808 sensor.
| def mcp9808.MCP9808.get_temp | ( | self, | |
unit = 'C' |
|||
| ) |
Returns the curent ambient temperature measured by the sensor.
This function returns the curent ambient temerature measurement of the MCO9808 sensor in Celcius, Fahrenheit, Kelvin, or Rankine.
| unit | A single character str designating the desired units can be 'C' 'F' 'K' or 'R' |
| def mcp9808.MCP9808.lower_lim | ( | self, | |
Temp = 'GET', |
|||
unit = 'C' |
|||
| ) |
Sets or gets the curent lower temperature alert limit of the sensor.
TXT
| def mcp9808.MCP9808.res | ( | self, | |
res = 'GET' |
|||
| ) |
Gets or sets the device measurement resolution.
This method gets or sets the sampling resolution for the MCP9808 temperature sensor. There are four valid resolution settings as outlined by the following:
0 = +0.05 C 1 = +0.25 C 2 = +0.125 C 3 = +0.0625 C
| res | The resolution index to set, if no value is passed, the current resolution index is returned. |
| def mcp9808.MCP9808.temp_to_bytes | ( | self, | |
| Temp | |||
| ) |
Converts a temperature in celcius to a bytearry for the MCP9808 sensor.
| Temp | The celcius temperature to be converted into bytes |
| mcp9808.MCP9808.addr |
The I2C adress of the sensor.
The adress is created by combining the four bit manufacturer address with the three bit user selected address.
| mcp9808.MCP9808.config |
The sensor configuration data.
See the MCP9808 datasheet for a detailed explanation of what this specifies.
| mcp9808.MCP9808.res |
The sensor resolution.
The value of res indexes the following list of available resolutions [+0.5, +0.25, +0.125, +0.0625] (units in Celcius)