Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4# Simple demo of the MAX31865 thermocouple amplifier.
5# Will print the temperature every second.
6import time
7import board
8import digitalio
9import adafruit_max31865
10
11
12# Create sensor object, communicating over the board's default SPI bus
13spi = board.SPI()
14cs = digitalio.DigitalInOut(board.D5) # Chip select of the MAX31865 board.
15sensor = adafruit_max31865.MAX31865(spi, cs)
16# Note you can optionally provide the thermocouple RTD nominal, the reference
17# resistance, and the number of wires for the sensor (2 the default, 3, or 4)
18# with keyword args:
19# sensor = adafruit_max31865.MAX31865(spi, cs, rtd_nominal=100, ref_resistor=430.0, wires=2)
20
21# Main loop to print the temperature every second.
22while True:
23 # Read temperature.
24 temp = sensor.temperature
25 # Print the value.
26 print("Temperature: {0:0.3f}C".format(temp))
27 # Delay for a second.
28 time.sleep(1.0)