Skip to content

devbret/mcp9808-sensor-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP9808 Sensor Project

Average hourly temperatures visualized over a period of time.

Code for combining a Raspberry Pi Zero 2 WH computer with an Adafruit MCP9808 temperature sensor to measure ambient air temperatures. The files in this repo are related to the following Hackaday.io project.

Overview

The Python script communicates with the MCP9808 using the I2C interface and logs temperature readings once per second. Each reading is timestamped and appended to a CSV file, creating a dataset of environmental temperature measurements. The program runs indefinitely until manually stopped, allowing the device to act as a lightweight temperature monitoring system.

After sufficient data has been collected, the CSV file can be transferred from the Raspberry Pi to another computer for analysis and visualization. The project includes frontend files which load the temperature dataset and generate several charts to help explore patterns in the data. Because the script records a reading every second, the dataset can grow quickly which may require additional processing time and memory when generating the visualizations.

Set Up Instructions

Below are the required software programs and instructions for using this application on a Raspberry Pi computer.

Programs Needed

Steps

  1. Install the above programs

  2. Open a terminal

  3. Clone this repository: git clone git@github.com:devbret/mcp9808-sensor-project.git

  4. Navigate to the repo's directory: cd mcp9808-sensor-project

  5. Create a virtual environment: python3 -m venv venv

  6. Activate your virtual environment: source venv/bin/activate

  7. Install the needed dependencies: pip install -r requirements.txt

  8. Run the primary script: python3 app.py

  9. Start a screen session: screen -S temp-logger

  10. Detatch: Ctrl+A, then D

  11. To later reattach: screen -r temp-logger

Other Considerations

This project repo is intended to demonstrate an ability to do the following:

  • Collect temperature readings from an MCP9808 sensor connected to a Raspberry Pi over I2C

  • Log timestamped temperature data every second into a CSV file for later analysis

  • Create a lightweight environmental monitoring system

If you have any questions or would like to collaborate, please reach out either on GitHub or via my website.

Please Note

There are three types of graphs available for exploring your temperature measurements. The first visualization displays average hourly temperatures as a line graph. The second (type of) chart displays an average twenty four hour period based on all of your readings. Whereas the third variety of charts displays each day's readings from when measurements began until their ending.

In my experience, the Python file will generate between two and three megabytes of data every twenty four hours. Although your results may vary.

Please Also Note

When attempting to load visualizations of your data, the process may take several minutes to complete. As well, you will likely consume more RAM than expected by doing so. Please take these points into consideration when launching your HTML, CSS and JavaScript files.

About

Code for combining a Raspberry Pi Zero 2 WH computer with an Adafruit MCP9808 temperature sensor to measure ambient air temperatures.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors