diff --git a/.gitignore b/.gitignore index ced7313..9bfdd9d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ _build *.pyc .env bundles +.idea diff --git a/README.rst b/README.rst index f6e6902..5012e8e 100644 --- a/README.rst +++ b/README.rst @@ -56,7 +56,7 @@ Usage Example Of course, you must import the library to use it: -.. code:: python +.. code:: python3 import adafruit_max31855 @@ -64,24 +64,23 @@ You also need to create an SPI interface object, and a pin object for the chip select pin. You can use any pin for the CS, but we use D5 here: -.. code:: python +.. code:: python3 - from busio import SPI from digitalio import DigitalInOut import board - spi = SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI) + spi = board.SPI() cs = DigitalInOut(board.D5) Next, just create the sensor object: -.. code:: python +.. code:: python3 sensor = adafruit_max31855.MAX31855(spi, cs) And you can start making measurements: -.. code:: python +.. code:: python3 print(sensor.temperature) diff --git a/adafruit_max31855.py b/adafruit_max31855.py index 5580744..e4a4d90 100644 --- a/adafruit_max31855.py +++ b/adafruit_max31855.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT """ -``adafruit_max31855`` +`adafruit_max31855` =========================== This is a CircuitPython driver for the Maxim Integrated MAX31855 thermocouple @@ -21,9 +21,11 @@ **Software and Dependencies:** -* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: - https://github.com/adafruit/circuitpython/releases +* Adafruit CircuitPython firmware for the supported boards: + https://circuitpython.org/downloads + * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice + """ import math @@ -41,6 +43,36 @@ class MAX31855: """ Driver for the MAX31855 thermocouple amplifier. + + :param ~busio.SPI spi: The SPI bus the MAX31856 is connected to. + :param ~microcontroller.Pin cs: The pin used for the CS signal. + + + **Quickstart: Importing and using the MAX31855** + + Here is an example of using the :class:`MAX31855` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + from digitalio import DigitalInOut, Direction + import adafruit_max31855 + + Once this is done you can define your `board.SPI` object and define your sensor object + + .. code-block:: python + + spi = board.SPI() + cs = digitalio.DigitalInOut(board.D5) # Chip select of the MAX31855 board. + sensor = adafruit_max31856.MAX31855(spi, cs) + + + Now you have access to the :attr:`temperature` attribute + + .. code-block:: python + + temperature = sensor.temperature """ def __init__(self, spi, cs): diff --git a/docs/index.rst b/docs/index.rst index cf4531e..1644f56 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,6 +23,8 @@ Table of Contents .. toctree:: :caption: Tutorials + MAX31855 Thermocouple Learning Guide + .. toctree:: :caption: Related Products diff --git a/examples/max31855_simpletest.py b/examples/max31855_simpletest.py index 7b882d1..7caece1 100644 --- a/examples/max31855_simpletest.py +++ b/examples/max31855_simpletest.py @@ -3,11 +3,10 @@ import time import board -import busio import digitalio import adafruit_max31855 -spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) +spi = board.SPI() cs = digitalio.DigitalInOut(board.D5) max31855 = adafruit_max31855.MAX31855(spi, cs)