/ examples / max31865_simpletest.py
max31865_simpletest.py
 1  # Simple demo of the MAX31865 thermocouple amplifier.
 2  # Will print the temperature every second.
 3  import time
 4  
 5  import board
 6  import busio
 7  import digitalio
 8  
 9  import adafruit_max31865
10  
11  
12  # Initialize SPI bus and sensor.
13  spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
14  cs = digitalio.DigitalInOut(board.D5)  # Chip select of the MAX31865 board.
15  sensor = 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.
22  while 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)