TempSensor_NXP_Arduino 0.3.0
Temperature sensor device operation sample code for Arduino
Loading...
Searching...
No Matches
TempSensor_NXP_Arduino

Temperature sensor device operation sample code for Arduino

Note

This library works with I2C_device library together. Please be sure the I2C_device library is imported in your environment before trying to build.

Boards
P3T1085UK-ARD and PCT2075DP-ARD : Arduino® Shield Evaluation Board for temperature sensors

What is this?

An Arduino library for I²C temperature sensors with sample code.
The I²C temperature sensors can measure temperature and output comparator or interrupt signals by threshold settings.

With TempSensor_NXP_Arduino library, the temperature measurement and showing it in Celsius can be done very simple as follwoing.

#include <PCT2075.h>
PCT2075 sensor;
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("\r***** Hello, PCT2075! *****");
}
void loop() {
float t = sensor.temp();
Serial.println(t);
delay(1000);
}
virtual float temp(void)
Definition: TempSensor.cpp:32

Supported devices

Type# Features Accuracy Resolution Interface Evaluation board
LM75B An industrial standard Digital Temperature Sensor ±2℃ 0.125℃ (11bit) I²C Fast-mode (400KHz)
PCT2075 I²C-Bus Fm+, 1 Degree C Accuracy, Digital Temperature Sensor ±1℃ 0.125℃ (11bit) I²C Fast-mode Plus (1MHz) PCT2075DP-ARD Arduino® Shield - Temperature Sensors
P3T1085 I3C/I²C-Bus ±0.5 °C Accurate Digital Temperature Sensor ±0.5℃ 0.0625℃ (12bit) I3C / I²C Fast-mode (400KHz) P3T1085UK Arduino® Shield Evaluation Board

Getting started

Install and run

Use Library manager in Arduino IDE for easy install

  • Find this library: Open the Library Manager pane, Search this library and click INSTALL button.
    Find the lib
  • Click **"INSTALL ALL"**
    Install all
  • Install will be completed quickly
    Install completed
  • Choose a sample code and try!
    Choosing a sample code

What's inside?

Temperature sensor library

LM75B, PCT2075 and P3T1085 class libraries are included. Those libraries can be used by just making an instance from those class.
Those libraries have common methods to get/set device information.

Method Role
temp() Get temperature in Celsius
read() Get temperature in Celsius (same as temp())
thresholds( v0, v1 ) Set high and low temperature threshold for OS output. v0 and v1 are needed to be given by Celsius value. Order of the arguments doesn't care
os_mode( mode ) Set OS pin mode. It can be set comparator or interrupt mode. The argument needs to be given as a class constant like PCT2075::COMPARATOR or PCT2075::INTERRUPT. The class name can be LM75B, PCT2075, P3T1085 or a generic name of TempSensor.

Examples

Example code is provided as scketch files.
For a quick access to those sketch, refer to last step of **"Getting started" section** of this document.

Sketch Feature
PCT2075_simple Simple sample for just reading temperature fro PCT2075 in every second
PCT2075DP-ARD_interrupt_by_Tos_Thyst Demo to use interrupt. The sketch sets thresholds +2℃ and +1℃ of temperature when starting. The sketch controls on-board heater to keep the temperature withon those thresholds.
P3T1085_simple Simple sample for just reading temperature fro P3T1085 in every second (Similar to PCT2075_simple)
P3T1085_interrupt Demo for interrupt behavior. On the P3T1085UK-ARD evaluation board, the D8 pin is used for interrupt output but it cannot be used on most of Arduino boards. The D2 pin is used for interrupt input on this sketch. So to perform the interrupt correctly, short D8 and D2 pins.

Document

For details of the library, please find descriptions in this document.

References

I²C Digital Temperature Sensors

Related libraries

Library Feature Target devices Required library
GPIO_NXP_Arduino LED driver libraries PCAL6408A, PCAL6416A, PCAL6524, PCAL6534 I2C_device_Arduino
LEDDriver_NXP_Arduino LED driver libraries PCA9955B, PCA9956B, PCA9957 I2C_device_Arduino
RTC_NXP_Arduino RTC driver libraries PCF2131, PCF85063A I2C_device_Arduino
TempSensor_NXP_Arduino Temperature sensor libraries LM75B, PCT2075, P3T1085 I2C_device_Arduino
I2C_device_Arduino Base library for I²C operations none (can be applied as base class for all I²C targets)