From e6d413dc58dc70434ce0bf525047cd08b6ce71bb Mon Sep 17 00:00:00 2001 From: Tony DiCola Date: Fri, 1 Dec 2017 01:48:26 -0800 Subject: [PATCH] Add example. --- README.rst | 4 ++-- examples/simpletest.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 examples/simpletest.py diff --git a/README.rst b/README.rst index f5fbec2..493eb27 100644 --- a/README.rst +++ b/README.rst @@ -10,7 +10,7 @@ Introduction :target: https://discord.gg/nBQh6qu :alt: Discord -TODO +CircuitPython module for the MAX31865 thermocouple amplifier. Dependencies ============= @@ -26,7 +26,7 @@ This is easily achieved by downloading Usage Example ============= -TODO +See examples/simpletest.py for a demo of the usage. Contributing ============ diff --git a/examples/simpletest.py b/examples/simpletest.py new file mode 100644 index 0000000..26f51e3 --- /dev/null +++ b/examples/simpletest.py @@ -0,0 +1,26 @@ +# Simple demo of the MAX31865 thermocouple amplifier. +# Will print the temperature every second. +import board +import busio +import time + +import adafruit_max31865 + + +# Initialize SPI bus and sensor. +spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) +cs = board.D5 # Chip select of the MAX31865 board. +sensor = adafruit_max31865.MAX31865(spi, cs) +# Note you can optionally provide the thermocouple RTD nominal, the reference +# resistance, and the number of wires for the sensor (2 the default, 3, or 4) +# with keyword args: +#sensor = adafruit_max31865.MAX31865(spi, cs, rtd_nominal=100, ref_resistor=430.0, wires=2) + +# Main loop to print the temperature every second. +while True: + # Read temperature. + temp = sensor.temperature + # Print the value. + print('Temperature: {0.3f}C'.format(temp)) + # Delay for a second. + time.sleep(1.0)