Adafruit_MicroPython_MAX31685/examples/max31865_simpletest.py

29 lines
997 B
Python
Raw Normal View History

2020-04-05 11:42:05 +02:00
"""Simple demo of the MAX31865 thermocouple amplifier.
Will print the temperature every second."""
import time
2020-03-29 18:04:38 +02:00
import machine
2017-12-01 10:48:26 +01:00
import adafruit_max31865
# Initialize SPI bus and sensor.
2020-04-05 11:42:05 +02:00
SPI = machine.SPI(-1, sck=machine.Pin(14, machine.Pin.OUT),
mosi=machine.Pin(13, machine.Pin.OUT),
miso=machine.Pin(12, machine.Pin.OUT)
)
SPI.init(baudrate=115200, polarity=0, phase=1)
CS = machine.Pin(2)
SENSOR = adafruit_max31865.MAX31865(SPI, CS)
2017-12-01 10:48:26 +01:00
# 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:
2020-03-15 23:41:20 +01:00
# sensor = adafruit_max31865.MAX31865(spi, cs, rtd_nominal=100, ref_resistor=430.0, wires=2)
2017-12-01 10:48:26 +01:00
# Main loop to print the temperature every second.
while True:
# Read temperature.
2020-04-05 11:42:05 +02:00
TEMP = SENSOR.temperature
2017-12-01 10:48:26 +01:00
# Print the value.
2020-04-05 11:42:05 +02: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)