Skip to content

Commit 7c1090a

Browse files
authored
Merge pull request #1 from cogliano/master
MCP9600 driver for CircuitPython
2 parents 7b86fe2 + 3520a43 commit 7c1090a

16 files changed

+1163
-2
lines changed

.pylintrc

Lines changed: 433 additions & 0 deletions
Large diffs are not rendered by default.

.readthedocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
python:
2+
version: 3
3+
requirements_file: requirements.txt

.travis.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This is a common .travis.yml for generating library release zip files for
2+
# CircuitPython library releases using circuitpython-build-tools.
3+
# See https://github.com/adafruit/circuitpython-build-tools for detailed setup
4+
# instructions.
5+
6+
dist: xenial
7+
language: python
8+
python:
9+
- "3.6"
10+
11+
cache:
12+
pip: true
13+
14+
# TODO: if deployment to PyPi is desired, change 'DEPLOY_PYPI' to "true",
15+
# or remove the env block entirely and remove the condition in the
16+
# deploy block.
17+
env:
18+
- DEPLOY_PYPI="false"
19+
20+
deploy:
21+
- provider: releases
22+
api_key: "$GITHUB_TOKEN"
23+
file_glob: true
24+
file: "$TRAVIS_BUILD_DIR/bundles/*"
25+
skip_cleanup: true
26+
overwrite: true
27+
on:
28+
tags: true
29+
# TODO: Use 'travis encrypt --com -r adafruit/<repo slug>' to generate
30+
# the encrypted password for adafruit-travis. Paste result below.
31+
- provider: pypi
32+
user: adafruit-travis
33+
password:
34+
secure: #-- PASTE ENCRYPTED PASSWORD HERE --#
35+
on:
36+
tags: true
37+
condition: $DEPLOY_PYPI = "true"
38+
39+
install:
40+
- pip install -r requirements.txt
41+
- pip install circuitpython-build-tools Sphinx sphinx-rtd-theme
42+
- pip install --force-reinstall pylint==1.9.2
43+
44+
script:
45+
- pylint adafruit_mcp9600.py
46+
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
47+
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-mcp9600 --library_location .
48+
- cd docs && sphinx-build -E -W -b html . _build/html && cd ..

CODE_OF_CONDUCT.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Adafruit Community Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and leaders pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level or type of
9+
experience, education, socio-economic status, nationality, personal appearance,
10+
race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
We are committed to providing a friendly, safe and welcoming environment for
15+
all.
16+
17+
Examples of behavior that contributes to creating a positive environment
18+
include:
19+
20+
* Be kind and courteous to others
21+
* Using welcoming and inclusive language
22+
* Being respectful of differing viewpoints and experiences
23+
* Collaborating with other community members
24+
* Gracefully accepting constructive criticism
25+
* Focusing on what is best for the community
26+
* Showing empathy towards other community members
27+
28+
Examples of unacceptable behavior by participants include:
29+
30+
* The use of sexualized language or imagery and sexual attention or advances
31+
* The use of inappropriate images, including in a community member's avatar
32+
* The use of inappropriate language, including in a community member's nickname
33+
* Any spamming, flaming, baiting or other attention-stealing behavior
34+
* Excessive or unwelcome helping; answering outside the scope of the question
35+
asked
36+
* Trolling, insulting/derogatory comments, and personal or political attacks
37+
* Public or private harassment
38+
* Publishing others' private information, such as a physical or electronic
39+
address, without explicit permission
40+
* Other conduct which could reasonably be considered inappropriate
41+
42+
The goal of the standards and moderation guidelines outlined here is to build
43+
and maintain a respectful community. We ask that you don’t just aim to be
44+
"technically unimpeachable", but rather try to be your best self.
45+
46+
We value many things beyond technical expertise, including collaboration and
47+
supporting others within our community. Providing a positive experience for
48+
other community members can have a much more significant impact than simply
49+
providing the correct answer.
50+
51+
## Our Responsibilities
52+
53+
Project leaders are responsible for clarifying the standards of acceptable
54+
behavior and are expected to take appropriate and fair corrective action in
55+
response to any instances of unacceptable behavior.
56+
57+
Project leaders have the right and responsibility to remove, edit, or
58+
reject messages, comments, commits, code, issues, and other contributions
59+
that are not aligned to this Code of Conduct, or to ban temporarily or
60+
permanently any community member for other behaviors that they deem
61+
inappropriate, threatening, offensive, or harmful.
62+
63+
## Moderation
64+
65+
Instances of behaviors that violate the Adafruit Community Code of Conduct
66+
may be reported by any member of the community. Community members are
67+
encouraged to report these situations, including situations they witness
68+
involving other community members.
69+
70+
You may report in the following ways:
71+
72+
In any situation, you may send an email to <[email protected]>.
73+
74+
On the Adafruit Discord, you may send an open message from any channel
75+
to all Community Helpers by tagging @community moderators. You may also send an
76+
open message from any channel, or a direct message to @kattni#1507,
77+
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
78+
@Andon#8175.
79+
80+
Email and direct message reports will be kept confidential.
81+
82+
In situations on Discord where the issue is particularly egregious, possibly
83+
illegal, requires immediate action, or violates the Discord terms of service,
84+
you should also report the message directly to Discord.
85+
86+
These are the steps for upholding our community’s standards of conduct.
87+
88+
1. Any member of the community may report any situation that violates the
89+
Adafruit Community Code of Conduct. All reports will be reviewed and
90+
investigated.
91+
2. If the behavior is an egregious violation, the community member who
92+
committed the violation may be banned immediately, without warning.
93+
3. Otherwise, moderators will first respond to such behavior with a warning.
94+
4. Moderators follow a soft "three strikes" policy - the community member may
95+
be given another chance, if they are receptive to the warning and change their
96+
behavior.
97+
5. If the community member is unreceptive or unreasonable when warned by a
98+
moderator, or the warning goes unheeded, they may be banned for a first or
99+
second offense. Repeated offenses will result in the community member being
100+
banned.
101+
102+
## Scope
103+
104+
This Code of Conduct and the enforcement policies listed above apply to all
105+
Adafruit Community venues. This includes but is not limited to any community
106+
spaces (both public and private), the entire Adafruit Discord server, and
107+
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
108+
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
109+
interaction at a conference.
110+
111+
This Code of Conduct applies both within project spaces and in public spaces
112+
when an individual is representing the project or its community. As a community
113+
member, you are representing our community, and are expected to behave
114+
accordingly.
115+
116+
## Attribution
117+
118+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119+
version 1.4, available at
120+
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
121+
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
122+
123+
For other projects adopting the Adafruit Community Code of
124+
Conduct, please contact the maintainers of those projects for enforcement.
125+
If you wish to use this code of conduct for your own project, consider
126+
explicitly mentioning your moderation policy or making a copy with your
127+
own moderation policy so as to avoid confusion.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Dan Cogliano for Adafruit Industries
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Introduction
2+
============
3+
4+
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-mcp9600/badge/?version=latest
5+
:target: https://circuitpython.readthedocs.io/projects/mcp9600/en/latest/
6+
:alt: Documentation Status
7+
8+
.. image:: https://img.shields.io/discord/327254708534116352.svg
9+
:target: https://discord.gg/nBQh6qu
10+
:alt: Discord
11+
12+
.. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_MCP9600.svg?branch=master
13+
:target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_MCP9600
14+
:alt: Build Status
15+
16+
This is a CircuitPython driver for the MCP9600 thermocouple I2C amplifier.
17+
In addition to the MCP9600 breakout, you will also need a thermocouple, which
18+
can be found in the Adafruit store.
19+
The MCP9600 supports several thermocouple types for different temperature
20+
ranges. The "K" type is the default, with a range of -200C to +1372C.
21+
22+
23+
Dependencies
24+
=============
25+
This driver depends on:
26+
27+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
28+
29+
Please ensure all dependencies are available on the CircuitPython filesystem.
30+
This is easily achieved by downloading
31+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
32+
33+
Usage Example
34+
=============
35+
36+
This is a simple example showing the hot junction temperature (the
37+
temperature at the tip of the thermocouple). You may need to adjust the
38+
I2C frequency if you receive input/output errors.
39+
40+
.. code-block:: shell
41+
42+
import board
43+
import busio
44+
from adafruit_bus_device.i2c_device import I2CDevice
45+
from adafruit_mcp9600 import MCP9600
46+
47+
i2c = busio.I2C(board.SCL, board.SDA,frequency=200000)
48+
try:
49+
# using default I2C register and "K" thermocouple
50+
device = MCP9600(i2c)
51+
print("temperature(C):",device.temperature)
52+
except ValueError:
53+
print("MCP9600 sensor not detected")
54+
55+
This example displays the ambient/room and hot junction temperatures at
56+
1 second intervals. Turn on the Mu editor's plotter option to view the
57+
temperatures in a real-time graph.
58+
59+
.. code-block:: shell
60+
61+
import board
62+
import busio
63+
import time
64+
from adafruit_bus_device.i2c_device import I2CDevice
65+
from adafruit_mcp9600 import MCP9600
66+
67+
i2c = busio.I2C(board.SCL, board.SDA, frequency=200000)
68+
69+
try:
70+
device = MCP9600(i2c)
71+
print("version:", device.version)
72+
while True:
73+
print((
74+
device.ambient_temperature,
75+
device.temperature
76+
))
77+
time.sleep(1)
78+
except ValueError:
79+
print("MCP9600 sensor not detected")
80+
81+
82+
Contributing
83+
============
84+
85+
Contributions are welcome! Please read our `Code of Conduct
86+
<https://github.com/adafruit/Adafruit_CircuitPython_MCP9600/blob/master/CODE_OF_CONDUCT.md>`_
87+
before contributing to help this project stay welcoming.
88+

0 commit comments

Comments
 (0)