Arduino Nano - TCN75A Temperature Sensor Tutorial
by Dcube Tech Ventures in Circuits > Electronics
4368 Views, 7 Favorites, 0 Comments
Arduino Nano - TCN75A Temperature Sensor Tutorial
TCN75A is a two-wire serial temperature sensor incorporated with temperature-to-digital converter. It is incorporated with user programmable registers that provide flexibility for temperature-sensing applications. The register settings allow users to configure power saving mode, shutdown mode, one shot mode etc.The sensor has an i2c compatible serial interface which can facilitate connection of upto eight devices in a single serial bus. Here is its demonstration with arduino nano.
What You Need..!!
Connection:
Take an I2C shield for Arduino Nano and gently push it over the pins of Nano.
Then connect the one end of I2C cable to TCN75A sensor and the other end to the I2C shield.
Connections are shown in the picture above.
Code:
The Arduino code for TCN75A can be downloaded from our Github repository-DCUBE Store.
Here is the link for the same :
https://github.com/DcubeTechVentures/TCN75A/blob/master/Arduino/TCN75A.ino
We include library Wire.h to facilitate the I2c communication of the sensor with the Arduino board. You can also copy the code from here, it is given as follows:
// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
// TCN75A
// This code is designed to work with the TCN75A_I2CS I2C Mini Module
#include
// TCN75A I2C address is 0x48(72)
#define Addr 0x48
void setup()
{
// Initialise I2C communication as Master
Wire.begin();
// Initialise serial communication, set baud rate = 9600
Serial.begin(9600);
// Start I2C transmission
Wire.beginTransmission(Addr);
// Select configuration register
Wire.write(0x01);
// 12-bit ADC resolution
Wire.write(0x60);
// Stop I2C transmission
Wire.endTransmission();
delay(300);
}
void loop()
{
unsigned int data[2];
// Start I2C transmission
Wire.beginTransmission(Addr);
// Select data register
Wire.write(0x00);
// Stop I2C transmission
Wire.endTransmission();
// Request 2 bytes of data
Wire.requestFrom(Addr, 2);
// Read 2 bytes of data
// temp msb, temp lsb
if (Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();
}
// Convert the data to 12-bits
int temp = (((data[0] * 256) + (data[1] & 0xF0)) / 16);
if(temp > 2047)
{
temp -= 4096;
}
float cTemp = temp * 0.0625;
float fTemp = (cTemp * 1.8) + 32;
// Output data to serial monitor
Serial.print("Temperature in Celsius : ");
Serial.print(cTemp); Serial.println(" C");
Serial.print("Temperature in Fahrenheit : ");
Serial.print(fTemp);
Serial.println(" F");
delay(1000);
}
Applications:
TCN75A is a temperature sensor that can be employed in personal computers and servers.It can also be deployed in entertainment systems,office equipments, hars disk drives and other PC peripherals.This sensor also find its application in data communication equipment.