Celsius Temperature Sensor Installation and Example Code
By Rusty
Introduction
This high-accuracy, fast-response temperature sensor comes sealed and ready to use for temperature profiling, lab measurements, and more!
Installation
1. Use a small amount of silicone grease on the O-ring for lubrication and place it in the groove of the Celsius Temperature Sensor.
2. Install the Celsius Temperature Sensor into an endcap and tighten by hand or with a wrench.
3. Insert the JST GH plug into the open I2C port on a Navigator Flight Controller (it has two I2C ports, so one is still free for use with the standard Bar30 connected), an I2C Bus Splitter if using with a Pixhawk, or an I2C Level Converter if using with an Arduino.
Example Code
Arduino
This example uses the TMP119 Arduino Library with the connected sensor. The example reads the sensor and prints the resulting values to the serial terminal.
The current Celsius connects directly to the Arduino, so no level converter is needed. If you’ve never used Arduino before, we suggest checking out some tutorials! You can find the TMP119 Arduino Library on our GitHub page.
Note: Older Celsius units (R1 and R2) use the TSYS01 Arduino Library and need a logic level converter, such as this one, to convert the Arduino’s 5V levels to 3.3V. Check your order against the revision history on the product page to determine which you have.
#include <Wire.h>
#include "TMP119.h"
// Optional constructor parameters: TMP119(address, wire)
// address – I2C address set by the ADD0 pin (default 0x48):
// 0x48 (GND), 0x49 (V+), 0x4A (SDA), 0x4B (SCL)
// wire – I2C bus to use (default &Wire)
// e.g. "TMP119 sensor;" is equivalent to "TMP119 sensor(0x48, &Wire);"
TMP119 sensor;
void setup() {
Serial.begin(9600);
Serial.println("Starting");
Wire.begin();
while (!sensor.init()) {
Serial.println("TMP119 device failed to initialize!");
delay(2000);
}
// Override the fast defaults set by init() with low-noise settings:
// average 64 conversions and update roughly once per second.
//
// Averaging options (setAveraging) and the time each takes per result:
// TMP119_AVERAGE_1X -> 15.5 ms
// TMP119_AVERAGE_8X -> 125 ms
// TMP119_AVERAGE_32X -> 500 ms
// TMP119_AVERAGE_64X -> 1 s
//
// Minimum standby delay options (setReadDelay):
// TMP119_DELAY_NONE, TMP119_DELAY_125_MS, TMP119_DELAY_250_MS,
// TMP119_DELAY_500_MS, TMP119_DELAY_1000_MS, TMP119_DELAY_4000_MS,
// TMP119_DELAY_8000_MS, TMP119_DELAY_16000_MS
//
// The actual time between readings is the greater of the averaging time
// above and the standby delay (datasheet Table 8-6). So 64x averaging with
// TMP119_DELAY_1000_MS gives ~1 s, but 64x with TMP119_DELAY_NONE is also
// ~1 s since the averaging itself takes 1 s.
sensor.setAveraging(TMP119_AVERAGE_64X);
sensor.setReadDelay(TMP119_DELAY_1000_MS);
}
void loop() {
sensor.read();
Serial.print("Temperature: ");
Serial.print(sensor.temperature());
Serial.println(" deg C");
Authors
Rusty
Rusty is the founder and CEO of Blue Robotics. His background is in engineering but he likes to be involved in everything at Blue Robotics!