ME 405 Portfolio
mcp9808.mcp9808 Class Reference

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...
 

Detailed Description

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.

Author
Jacob Everest
Hunter Morse
Date
Feb. 10, 2021

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
object_namethe name of an I2C object already created by the user
addressthe location of the I2C device on the nucleo
Author
Hunter Morse
Jacob Everest
Date
Feb. 2, 2021

Member Function Documentation

◆ celsius()

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.

Parameters
None
Author
Hunter Morse
Jacob Everest
Date
Feb. 10, 2021

◆ check()

def mcp9808.mcp9808.check (   self)

Checks the Location.

Checks the location of the I2C device on the nucleo

Parameters
None
Author
Hunter Morse
Jacob Everest
Date
Feb. 10, 2021

◆ fahrenheit()

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.

Parameters
None
Author
Hunter Morse
Jacob Everest
Date
Feb. 10, 2021

Member Data Documentation

◆ address

mcp9808.mcp9808.address

Device Address.

Address to use for interfacing with the device

◆ object_name

mcp9808.mcp9808.object_name

Name.

name of the object that we have decided to use for our I2C


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