How to use the TCN75 temperature sensor with Arduino

In this short tutorial I'm going to show to you how to implement , in the Arduino UNO environment, the basic functionalities to work with the TCN75.


Materials needed for this tutorial.

  • 1 Arduino UNO board (naturally)
  • Arduino IDE (naturally)
  • 1 TCN75 (naturally I'll use my own board, see related posts)
  • 4 jumper cables


Our tcn75 board is described here:


Ok let's start

Some theory

The TCN75 works trough the i2c bus, so what is the i2c bus?

I2C is an acronym for “Inter-Integrated Circuit”. In the late 1970s, Philips’ semiconductor division (now NXP) saw the need for simplifying and standardising the data lines that travel between various integrated circuits in their products. Their solution was the I2C bus. This reduced the number of wires to two (SDA – data, and SCL – clock). Here is a nice introductory video from NXP

From a hardware perspective, the wiring is very easy. Those of you with an Arduino Duemilanove, Uno or 100% compatible board, you will be using pins A4 for SDA (data) and A5 for SCL (clock).


If you are using an Arduino Mega, SDA is pin 20 and SCL is 21, so note that shields with I2C need to be specifically for the Mega. If you have another type of board, check your data sheet or try the Arduino team’s hardware website. And finally, if you are using a bare DIP ATmega328-PU microcontroller, you will use pins 27 for SDA and 28 for SCL.



Connecting Arduino to the TCN75 board

In the following table you'll find all the connections between Arduino and the TCN75 board

 

Arduino TCN75
5V V+
GND V-
A4 SD
A5 SC


That's all, now you only need to connect the USB plug to Arduino and to your PC. You should see the red led on the TCN75 lightned


Programming

First of all we need a function to convert temperature (TCN75 format) to  Celsius (float).


float tcn75_convertTemp(byte aa, byte bb);


This function returns the temperature value expressed in Celsius starting from the two bytes representation of the TCN75.



To use the i2c bus Arduino needs to initialize the Wire library, so in the setup function we will put this initialization:

 Wire.begin();

And to debug our code we will put also the following initialization:

 Serial.begin(115200)


Then we need to read the temperature:


tcn75_getTemperature


In pseudo code the tcn75_getTemperature will look like the following



Here you are a simple working sample.

 

The TCN75 provides a lot of other complex functions such as a setpoint, alarm, goto the links at the beginning of the article to see all its functionalities


Gg1


You may also like...

2 Responses

  1. Doug Wendelboe says:

    Have you posted firmware for this project somewhere. Sorry if I have ovelooked the URL to it. Thanks.

  2. admin says:

    To use the TCN75 with an Arduino board you don’t need any firmware, you have to connect the TCN75 with your arduino board…. nothing more

Leave a Reply

Your email address will not be published. Required fields are marked *