Thermocouple Phidget

The Thermocouple Phidget allows you to measure a wide range of temperatures.

The Thermocouple Phidget returns temperature in degrees Celsius (symbol: °C) and can be used in flames and liquids.

See tutorial

Setup

Before you do any coding you will have to attach your Thermocouple to your Phidget ( red = +, white = -) and your Phidget to your VINT hub as shown:

Code (Java)

Create a file called Thermocouple and insert the following code. Run your code. Hold the end of the thermocouple to change the temperature.

Not your programming language? Set my language and IDE.

  
package thermocouple;

//Add Phidgets Library
import com.phidget22.*;

public class Thermocouple {
    public static void main(String[] args) throws Exception{
        
	//Create
        TemperatureSensor temperatureSensor = new TemperatureSensor();
        
        //Open
        temperatureSensor.open(1000);

        //Use your Phidgets
        while(true){
            System.out.println("Temperature: " + temperatureSensor.getTemperature() +" °C");
            Thread.sleep(250);
        }
    }
}
  
  
//Add Phidgets Library
import com.phidget22.*;

public class Thermocouple {
    public static void main(String[] args) throws Exception{
        
	//Create
        TemperatureSensor temperatureSensor = new TemperatureSensor();
        
        //Open
        temperatureSensor.open(1000);

        //Use your Phidgets
        while(true){
            System.out.println("Temperature: " + temperatureSensor.getTemperature() +" °C");
            Thread.sleep(250);
        }
    }
}
  
  
//Add Phidgets Library
import com.phidget22.*;

//Define
TemperatureSensor temperatureSensor;

void setup(){
  try{
    
    //Create 
    temperatureSensor = new TemperatureSensor();

    //Open
    temperatureSensor.open(1000);
    
  }catch(Exception e){
    e.printStackTrace();
  }
}

void draw(){
  try{
    
    //Use your Phidgets
    println("Temperature: " + temperatureSensor.getTemperature() +" °C");
    delay(250);
    
  }catch(Exception e){
    e.printStackTrace();
  }
}
  

Code (Python)

Create a file called Thermocouple and insert the following code. Run your code. Hold the end of the thermocouple to change the temperature.

Not your programming language? Set my language and IDE.

  
#Add Phidgets Library
from Phidget22.Phidget import *
from Phidget22.Devices.TemperatureSensor import *
#Required for sleep statement
import time

#Create
temperatureSensor = TemperatureSensor()

#Open
temperatureSensor.openWaitForAttachment(1000)

#Use your Phidgets
while(True):
    print("Temperature: " + str(temperatureSensor.getTemperature()) + " °C")
    time.sleep(0.25)
  

Code (C#)

Create a file called Thermocouple and insert the following code. Run your code. Hold the end of the thermocouple to change the temperature.

Not your programming language? Set my language and IDE.

  
//Add Phidgets Library
using Phidget22;

namespace Thermocouple{
    class Program{
        static void Main(string[] args){

            //Create
            TemperatureSensor temperatureSensor = new TemperatureSensor();

            //Open
            temperatureSensor.Open(1000);

            //Use your Phidgets
            while (true){
                System.Console.WriteLine("Temperature: " + temperatureSensor.Temperature + " °C");
                System.Threading.Thread.Sleep(250);
            }
        }
    }
}
  

Code (Swift)

Create a file called Thermocouple and insert the following code. Run your code. Hold the end of the thermocouple to change the temperature.

Not your programming language? Set my language and IDE.

You will need to add three Labels.

  
import Cocoa
//Add Phidgets Library
import Phidget22Swift

class ViewController: NSViewController {

    @IBOutlet weak var sensorLabel: NSTextField!
    
    //Create
    let temperatureSensor = TemperatureSensor()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        do{
            //Subscribe to events
            let _ = temperatureSensor.temperatureChange.addHandler(onTemperatureChange)
            
            //Open
            try temperatureSensor.open()
            
        }catch{
            print(error)
        }
    }
    
    func onTemperatureChange(sender:TemperatureSensor, temperature: Double){
        DispatchQueue.main.async {
	    //Use information from your Phidget to change label
            self.sensorLabel.stringValue = String(temperature) + " °C"
        }
    }
}
  

Applications

Thermocouples are used in thermometers and diagnostic testing tools for vehicles. Thermocouples monitor temperature in things like boilers, water heaters, and ovens. Thermocouples are used across the food industry to monitor temperatures. For example, coffee roasters use Phidget thermocouples to monitor bean temperature during the roasting process.

Practice

You can easily create a Phidget mood sensor with the Thermocouple Phidget. Set a few different temperature ranges and assign a mood to each.

Have a user hold the end of your thermocouple and use their temperature to predict their mood.

Check out the advanced lesson Using the Sensor API before you use the API for the first time.

API
Troubleshoot
  1. Make sure everything is plugged in properly and your VINT Hub is connected to your computer
  2. Stop running other programs that are using your Phidgets before running a program.

If these do not solve your issue visit the Advanced Troubleshooting Page.

What are Phidgets?

Phidgets are programmable, modular USB devices, either sensors or controllers that you can connect together. Simply write code in your favorite language and solve real-world problems.

Learn more

Set your preferences

Windows

Mac OS

Raspberry Pi

Java

Python

C#

Swift

NetBeans

Processing

Eclipse

Thonny

PyCharm

PyScripter

Visual Studio

Xcode

Setting your preferred operating system, programming language and environment lets us display relevant code samples for the Getting Started Tutorial, Device Tutorials and Projects

Done