It's easy to wire this breakout to a microcontroller to use with the Arduino IDE. Keep in mind the output sensitivity is only 0.005 volts per degree Celsius. This is due to the overall large range of temperatures that can be measured.
If you are using a low resolution ADC (like 10 bits or less) and trying to discern small temperature differences (like only a couple of degrees), it may be difficult to pull that signal out of the noise.
For example, the Microchip SAMD21 M0 boards such as the Adafruit Metro M0 Express offer 12 bit analog inputs.
- Board V+ to Metro 3.3V
- Board GND to Metro GND
- Board OUT to Metro A0
- Board RED- to thermocouple red- wire
- Board YLW+ to thermocouple yellow+ wire
// SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries // // SPDX-License-Identifier: MIT // #define TC_PIN A0 // set to ADC pin used #define AREF 3.3 // set to AREF, typically board voltage like 3.3 or 5.0 #define ADC_RESOLUTION 10 // set to ADC bit resolution, 10 is default float reading, voltage, temperature; float get_voltage(int raw_adc) { return raw_adc * (AREF / (pow(2, ADC_RESOLUTION)-1)); } float get_temperature(float voltage) { return (voltage - 1.25) / 0.005; } void setup() { Serial.begin(9600); } void loop() { reading = analogRead(TC_PIN); voltage = get_voltage(reading); temperature = get_temperature(voltage); Serial.print("Temperature = "); Serial.print(temperature); Serial.println(" C"); delay(500); }
Open the file you downloaded in the Arduino IDE, and upload it to your Arduino. Once uploaded to your Arduino, open up the serial console at 9600 baud speed to see data being printed out.
Usage
First, set the ADC pin to be used, choose the voltage you'll be connecting to, set the ADC resolution and set reading
, voltage
and temperature
to floats.
#define TC_PIN A0 // set to ADC pin used #define AREF 3.3 // set to AREF, typically board voltage like 3.3 or 5.0 #define ADC_RESOLUTION 10 // set to ADC bit resolution, 10 is default float reading, voltage, temperature;
Next are two functions: one to take the raw ADC value and turn it into voltage, and one to turn the voltage into temperature.
float get_voltage(int raw_adc) { return raw_adc * (AREF / (pow(2, ADC_RESOLUTION)-1)); } float get_temperature(float voltage) { return (voltage - 1.25) / 0.005; }
The get_voltage
function uses the raw ADC value, and the board voltage and resolution specified above to calculate the output voltage. Check out this Arduino tutorial for more information.
The get_temperature
function takes the output voltage from the get_voltage
function and uses it to calculate the temperature.
In the main loop, we take the analog reading
, apply it to get_voltage
to get voltage
, and then apply the voltage
to get_temperature
to get temperature
. Then we print the temperature to the serial monitor every 0.5 seconds.
reading = analogRead(TC_PIN); voltage = get_voltage(reading); temperature = get_temperature(voltage); Serial.print("Temperature = "); Serial.print(temperature); Serial.println(" C"); delay(500);
Page last edited January 22, 2025
Text editor powered by tinymce.