TempSensor_NXP_Arduino 0.3.0
Temperature sensor device operation sample code for 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.
P3T1085UK-ARD and PCT2075DP-ARD : Arduino® Shield Evaluation Board for temperature sensors
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.
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 |
Use Library manager in Arduino IDE for easy install
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 . |
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. |
For details of the library, please find descriptions in this document.
I²C Digital Temperature Sensors
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) | — |