ME 405: Mechatronics Portfolio
mcp9808_young.MCP9808 Class Reference

MCP9808 temperature sensor breakout board I2C class
More...

Public Member Functions

def __init__ (self, i2cObject, address)
  MCP9808 semperature sensor class constructor
More...
 
def check (self)
  Verify sensor address
More...
 
def celsius (self)
  Return measured temperature in degrees Celcius
More...
 
def fahrenheit (self)
  Return measured temperature in degrees Fahrenheit
More...
 

Public Attributes

 i2c
 Define class-specific I2C object from user-specified I2C object.
 
 address
 Define I2C bus address for MCP9808 from user-specified address.
 

Detailed Description

MCP9808 temperature sensor breakout board I2C class

This class is used for I2C communication between the NUCLEO and the MCP9808 temperature sensor breakout board. It has methods for checking the validity of the I2C connection between the NUCLEO and MCP9808, reading the temperature in degC, and reading the temperature in degF.

Constructor & Destructor Documentation

◆ __init__()

def mcp9808_young.MCP9808.__init__ (   self,
  i2cObject,
  address 
)

MCP9808 semperature sensor class constructor

Two inputs are required to construct an MCP9808 breakout board temperature sensor I2C communication object: first, a pyb.I2C object, and second, the address of the MCP9808 in the I2C bus. The constructor then defines a class-specific I2C object, defined as a "master" (yuck), and a class-specific variable to hold the MCP9808 address.

Parameters
i2cObjectThe I2C communication protocol object which is to be used for communication between the NUCLEO MCU and MCP9808 temperature sensor
addressThe I2C bus address of the MCP9808 temperature sensor

Member Function Documentation

◆ celsius()

def mcp9808_young.MCP9808.celsius (   self)

Return measured temperature in degrees Celcius

This method uses the pyb.I2C class method mem_read() to read the sensor temperature into a 2-byte bytearray. The address of the sensor and the memory address for the data is also specified. It then manipulates the raw byte data to represent the temperature in degrees Celsius.

◆ check()

def mcp9808_young.MCP9808.check (   self)

Verify sensor address

This method uses the pyb.I2C class method is_ready(addr), with the sensor I2C address as an input, to verify if a valid connection has been made between the NUCLEO and sensor.

◆ fahrenheit()

def mcp9808_young.MCP9808.fahrenheit (   self)

Return measured temperature in degrees Fahrenheit

his method uses the pyb.I2C class method mem_read() to read the sensor temperature into a 2-byte bytearray. The address of the sensor and the memory address for the data is also specified. It then manipulates the raw byte data to represent the temperature in degrees Fahrenheit.


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