Reads MCP9808 Data. More...
Public Member Functions | |
| def | __init__ (self, object_name, address) |
| Initialization Function. More... | |
| def | check (self) |
| Checks the Location. More... | |
| def | celsius (self) |
| Measures the temperature in celsius. More... | |
| def | fahrenheit (self) |
| Measures the temperature in celsius. More... | |
Public Attributes | |
| object_name | |
| Name. More... | |
| address | |
| Device Address. More... | |
Reads MCP9808 Data.
Input a premade object and the address of the I2C device to read from. Call this class and the method of either check, celsius, or fahrenheit. Check will return the address of the device, celsius will return the temperature in degrees celsius, and fahrenheit will return the temperature in degrees fahrenheit.
| def mcp9808.mcp9808.__init__ | ( | self, | |
| object_name, | |||
| address | |||
| ) |
Initialization Function.
Stores the parameters input by the user when creating the class object so that they may be used later by other functions.
| object_name | the name of an I2C object already created by the user |
| address | the location of the I2C device on the nucleo |
| def mcp9808.mcp9808.celsius | ( | self | ) |
Measures the temperature in celsius.
Reads the data from the MCP9808 in the form of two bytes. It Takes the important sign information from the the bit five of the first bit, then gets rid of the four MSBs in that bit. It then bit shifts to the left four times on that same byte. It bit shifts to the right four times on the second byte, then combines the two into one. Then it checks to see if the sign bit was one, thereby declaring the reading to be negative. If it was, then it subratracts the value from 256, if not it does nothing and returns that value as thetemperature.
| None |
| def mcp9808.mcp9808.check | ( | self | ) |
Checks the Location.
Checks the location of the I2C device on the nucleo
| None |
| def mcp9808.mcp9808.fahrenheit | ( | self | ) |
Measures the temperature in celsius.
Reads the data from the MCP9808 in the form of two bytes. It Takes the important sign information from the the bit five of the first bit, then gets rid of the four MSBs in that bit. It then bit shifts to the left four times on that same byte. It bit shifts to the right four times on the second byte, then combines the two into one. Then it checks to see if the sign bit was one, thereby declaring the reading to be negative. If it was, then it subratracts the value from 256, if not it does nothing. It converts from celsius to fahrenheit, then it returns that value as thetemperature.
| None |
| mcp9808.mcp9808.address |
Device Address.
Address to use for interfacing with the device
| mcp9808.mcp9808.object_name |
Name.
name of the object that we have decided to use for our I2C