Particle Photon TMP112 Temperature Sensor Tutorial

by Dcube Tech Ventures in Circuits > Electronics

26 Views, 0 Favorites, 0 Comments

Particle Photon TMP112 Temperature Sensor Tutorial

Particle Photon TMP112 Temperature Sensor Tutorial

TMP112 High-Accuracy, Low-Power, Digital Temperature Sensor I2C MINI module. The TMP112 is ideal for extended temperature measurement. This device offers an accuracy of ±0.5°C without requiring calibration or external component signal conditioning. Here is the demonstration of using it with particle photon.

What You Need..!!

IMG_2734.JPG
Particle-26_large.jpg

Connections

IMG_2734.JPG
Particle-26_large.jpg
sensor.jpg
IMG_2808.JPG

Take an I2C shield for particle photon and gently push it over the pins of particle photon.

Then connect the one end of I2C cable to TMP112 sensor and the other end to the I2C shield.

Connections are shown in the picture above.

Code:

IMG_2808.JPG

The particle code for TMP112 can be downloaded from our GitHub repository- Dcube Store.

Here is the link for the same :

https://github.com/DcubeTechVentures/TMP112

The datasheet of TMP112 can be found here:

http://www.ti.com/lit/ds/symlink/tmp112.pdf

We have used two libraries for particle code, which are application.h and spark_wiring_i2c.h. Spark_wiring_i2c library is required to facilitate the I2C communication with the sensor.

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.

// TMP112

// This code is designed to work with the TMP112_I2CS I2C Mini Module available in Dcube Store.

#include

#include
// TMP112 I2C address is 0x48(72)

#define Addr 0x48

float cTemp = 0, fTemp = 0;

void setup()

{

// Set variable

Particle.variable("i2cdevice", "TMP112");

Particle.variable("cTemp", cTemp);

// 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);

// Continuous conversion, comparator mode, 12-bit resolution

Wire.write(0x60);

Wire.write(0xA0);

// Stop I2C Transmission

Wire.endTransmission();

delay(300);

}

void loop()

{

unsigned int data[2];

// Start I2C Transmission

Wire.beginTransmission(Addr);

// Select temperature data register

Wire.write(0x00);

// Stop I2C Transmission

Wire.endTransmission(); delay(300);

// 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])) / 16;

if(temp > 2048)

{

temp -= 4096;

}

cTemp = temp * 0.0625;

fTemp = cTemp * 1.8 + 32;

// Output data to dashboard

Particle.publish("Temperature in Celsius : ", String(cTemp));

Particle.publish("Temperature in Fahrenheit: ", String(fTemp));

delay(800);

}

Applications..:

Various applications incorporating TMP112 low power, high accuracy digital temperature sensor include Power-Supply Temperature Monitoring, Computer Peripheral Thermal Protection, Battery Management as well as office machines.