ME405: Mechatronics
Project Documentation and Portfolio by Neil Patel
Lab0x04: Hot or Not?

Summary

The objective of this lab is to create and test a driver for an I2C-connected sensor and use that sensor to log some data. The sensor in question is going to be an MCP9808 temperature sensor and the data collected will be the surrounding ambient temperature in an 8 hour window.

Design Features

The MCP9808 temperature sensor uses an I2C interface to communicate with the MCU. In this assignment, the MCP can be utilized using only its power, ground, and two I2C communication pins (SDA and SCL). A pin diagram for the MCU-MCP connection is shown below:

Figure 1: Pin Diagram for I2C Connection

This program contains a class that allows the user to communicate with the MCP using its I2C interface. The class is able to initialize itself using an I2C object and the MCP address on the I2C interface, verify that the sensor is attached at the given bus address, and measure the temperature in degrees Celcius and Fahrenheit. The program also measures the internal temperature of the MCU and records both temperatures in degrees Celcius every 60 seconds. Data is taken until the user presses "Ctrl+C" or till the time limit is reached. Data is then saved in a CSV file and plotted.

Overview

Since the sensor was placed in a room which was thermally regulated by a thermostat, the temperature vs. time plot is nearly a straight line. Same case with the MCU temperature readings as the temperature measured is internal to the microcontroller. The y-axis is temperature in degrees Celcius and the x-axis is time in seconds. The readings were taken in an 8-hour window from 2 pm to 10 pm. Series 1 is the internal temperature of the MCU (steady at rougly -5 degrees Celcius) and Series 2 is the readings from the temperature sensor (steady at roughly 22 degrees Celcius). The plot is shown in the figure below:

Figure 2: Temperature vs. Time Plot

Documentation

Documentation of this lab can be found here: Lab0x04
A copy of the CSV file can be found here: https://bitbucket.org/npatel68/me405_labs/src/master/lab4/temps.csv

Source Code

The source code for this lab:
https://bitbucket.org/npatel68/me405_labs/src/master/lab4/mcp9808.py
https://bitbucket.org/npatel68/me405_labs/src/master/lab4/main.py


Author
Neil Patel
Date
May 13, 2021