Wiring

Wiring the PCT2075 to communicate with your microcontroller is straight forward thanks to the I2C interface. For these examples we can use the Metro or Arduino to take temperature measurements. The instructions below show a Metro, but the same applies to an Arduino

  •  Connect board VCC (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
  • Connect board GND (black wire) to Arduino GND
  • Connect board SCL (yellow wire) to Arduino SCL
  • Connect board SDA (blue wire) to Arduino SDA

Library Installation

Once wired up, to start using the PCT2075 you'll need to install the Adafruit_PCT2075 library. The library is available through the Arduino library manager so we recommend taking that approach.

From the Arduino IDE, open up the Library Manager:

Click the Manage Libraries ... menu item, search for Adafruit PCT2075, and select the Adafruit PCT2075 library and click Install:

Then follow the same process for the Adafruit BusIO library.

Basic Temperature Example

Open up File -> Examples -> Adafruit PCT2075 -> pct2075_test and upload to your Arduino wired up to the sensor.

One you've uploaded the sketch to your board open up the Serial Monitor (Tools->Serial Monitor) at 115200 baud. You should see the temperature readings being printed like so:

The temperature will be different depending on the weather where you are. You can see it change by either putting a particularly warm finger on the sensor, or by blowing hot air across it with a hot air station (not too hot!) or a hair dryer.

Temperature Alert Example

Next we'll wire up an LED with a current limiting resistor to the INT pin on the PCT2075 and then ask the PCT2075 to tell us when a certain temperature has been reached.

To start we'll take the wiring for the previous example and add the LED and resistor:

  •  Connect sensor VCC (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
  • Connect sensor GND (black wire) to Arduino GND
  • Connect sensor SCL (yellow wire) to Arduino SCL
  • Connect sensor SDA (blue wire) to Arduino SDA
  • Connect sensor INT to Resistor leg 1
  • Connect LED Cathode to Resistor leg 2
  • LED Anode to Arduino 5V

Open up File -> Examples -> Adafruit PCT2075 -> temp_alert_demo and upload to your Arduino wired up to the sensor.

Upload the sketch to your board and open up the Serial Monitor (Tools->Serial Monitor) at 115200 baud. You should see the current value of the various temperature alert settings printed out, followed by temperature measurements:

Temperature Alert Settings

High temperature threshold is the temperature that the sensor compares to the measured temperature each time it makes a measurement. If the current temperature is greater than or equal to the high temperature threshold, the sensor registers a temperature fault. What happens with that alert depends on the rest of the settings.

Temperature hysteresis is the temperature that defines the bottom of the "active" range of temperature where the sensor sill considers the temperature fault as being active. This temperature must be less than the high temperature threshold.

The fault count is how many consecutive temperature faults are required to raise an alert on the INT pin. In the example code the fault count is set to 4 meaning that four measurements by the sensor in a row must be equal to or greater than the high temperature threshold for the sensor to raise an alert.

Handy Interstitial Diagram

This diagram from the datasheet shows how the different parameters work together. High temperature threshold (here as Tots and temperature hysteresis (Thys) together define a temperature range that specify when the INT pin (OS) responds to, depending on the alert mode.

adafruit_products_temp_alert_ds_diagram.png
From the datasheet: https://www.nxp.com/docs/en/data-sheet/PCT2075.pdf

Alert Modes

The Alert mode dictates how the INT pin will be used to communicate with the user about the state of the temperature monitoring. In Comparator mode like in the example, the sensor acts similar to a thermostat controlling an air conditioning unit. When the sensor raises a high temperature alert according to the high temperature threshold and fault count, the INT pin is connected to ground, completing the LED circuit and lighting the LED. Once the temperature falls below the temperature hysteresis, the sensor puts the INT pin in a high impedance state, effectively disconnecting the LED from ground.

With the sensor in Comparator mode, the sensor can control a cooling mechanism such as a fan by having the INT pin activate a transistor or relay that controls the current flowing to the fan's motor. This way the decision of when to activate the fan is controlled directly by the PCT2075, allowing the microcontroller to focus on other things.

In Interrupt mode the sensor activates the INT pin twice: once when the alert is first raised, and a second time when the temperature falls below the temperature hysteresis. In interrupt mode the INT pin is deactivated by reading from the sensor.

Activating the Temperature Alert

Once wired as above, find a way to safely warm up the PCT2075 (definitely NOT with fire), and once it is past the threshold temperature of 32.5 degrees C (90.5 degrees F) for four consecutive measurementsthe LED will light up until the temperature again falls below the temperature hysteresis.

If you aren't able to get the temperature up to 32.5 degrees, you can modify the  temperature threshold and hysteresis so that they're in a range that is manageable.

Temperature Example Code

#include <Adafruit_PCT2075.h>


Adafruit_PCT2075 PCT2075;

void setup() {
  PCT2075 = Adafruit_PCT2075();

  Serial.begin(115200);
  // Wait until serial port is opened
  while (!Serial) { delay(1); }
  Serial.println("Adafruit PCT2075 Test");

  if (!PCT2075.begin()) {
    Serial.println("Couldn't find PCT2075 chip");
    while (1);
  }
  
  Serial.println("Found PCT2075 chip");

}

void loop() {
  Serial.print("Temperature: "); Serial.print(PCT2075.getTemperature());Serial.println(" C");
  delay(1000);
}

Temperature Alert Example Code

#include <Adafruit_PCT2075.h>


Adafruit_PCT2075 pct;

void setup() {
  pct = Adafruit_PCT2075();

  Serial.begin(115200);
  // Wait until serial port is opened
  while (!Serial) { delay(1); }
  Serial.println("Adafruit PCT2075 Test");

  if (!pct.begin()) {
    Serial.println("Couldn't find PCT2075 chip");
    while (1);
  }
  
  Serial.println("Found PCT2075 chip");
  pct.setIdleTime(1.0);
  pct.setActiveHigh(true); 
  
  pct.setHighTemperatureThreshold(32.5);
  Serial.print("High temperature threshold: ");Serial.print(pct.getHighTemperatureThreshold()); Serial.println("");
  
  pct.setTemperatureHysteresis(30.5);
  Serial.print("Temperature hysteresis: ");Serial.print(pct.getTemperatureHysteresis()); Serial.println("");
  
  pct.setMode(PCT2075_MODE_COMPARITOR);
  Serial.print("Alert mode set to: ");
  switch (pct.getMode()) {
    case PCT2075_MODE_INTERRUPT: Serial.println("Interrupt"); break;
    case PCT2075_MODE_COMPARITOR: Serial.println("Comparitor"); break;
  }

  pct.setFaultCount(PCT2075_FAULT_COUNT_4); // since the loop timing and idle delay are in sync, it will take 4 loops to fault
  Serial.print("Fault count set to: ");
  switch (pct.getFaultCount()) {
    case PCT2075_FAULT_COUNT_1: Serial.println("1"); break;
    case PCT2075_FAULT_COUNT_2: Serial.println("2"); break;
    case PCT2075_FAULT_COUNT_4: Serial.println("4"); break;
    case PCT2075_FAULT_COUNT_6: Serial.println("6"); break;
  }
  
}

void loop() {
  // checking every
  Serial.print("Temperature: "); Serial.print(pct.getTemperature());Serial.println(" C");
  delay(1000); // wait one second to match the idle time
}
This guide was first published on Sep 25, 2019. It was last updated on Sep 25, 2019.
This page (Arduino) was last updated on Oct 21, 2020.