2017-12-01 10:48:26 +01:00
|
|
|
# Simple demo of the MAX31865 thermocouple amplifier.
|
|
|
|
# Will print the temperature every second.
|
|
|
|
import board
|
|
|
|
import busio
|
2017-12-02 00:52:35 +01:00
|
|
|
import digitalio
|
2017-12-01 10:48:26 +01:00
|
|
|
import time
|
|
|
|
|
|
|
|
import adafruit_max31865
|
|
|
|
|
|
|
|
|
|
|
|
# Initialize SPI bus and sensor.
|
|
|
|
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
|
2017-12-02 00:54:52 +01:00
|
|
|
cs = digitalio.DigitalInOut(board.D5) # Chip select of the MAX31865 board.
|
2017-12-01 10:48:26 +01:00
|
|
|
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.
|
2017-12-02 00:52:35 +01:00
|
|
|
print('Temperature: {0:0.3f}C'.format(temp))
|
2017-12-01 10:48:26 +01:00
|
|
|
# Delay for a second.
|
|
|
|
time.sleep(1.0)
|