Simple test
Ensure your device works with this simple test.
examples/max31865_simpletest.py
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
7
8import board
9import digitalio
10
11import adafruit_max31865
12
13# Create sensor object, communicating over the board's default SPI bus
14spi = board.SPI()
15cs = digitalio.DigitalInOut(board.D5) # Chip select of the MAX31865 board.
16sensor = adafruit_max31865.MAX31865(spi, cs)
17# Note you can optionally provide the thermocouple RTD nominal, the reference
18# resistance, and the number of wires for the sensor (2 the default, 3, or 4)
19# with keyword args:
20# sensor = adafruit_max31865.MAX31865(spi, cs, rtd_nominal=100, ref_resistor=430.0, wires=2)
21
22# Main loop to print the temperature every second.
23while True:
24 # Read temperature.
25 temp = sensor.temperature
26 # Print the value.
27 print(f"Temperature: {temp:0.3f}C")
28 # Delay for a second.
29 time.sleep(1.0)