Interfacing TMP-112 With Arduino Nano (I2C)
by Dcube Tech Ventures in Circuits > Arduino
2028 Views, 0 Favorites, 0 Comments
Interfacing TMP-112 With Arduino Nano (I2C)
Hello,
Good Greetings..!!
I (Somanshu Choudhary) on the behalf of Dcube tech ventures going to measure temperature using Arduino nano, it is one of the applications of I2C protocol to read analog data of temperature Sensor TMP-112.
Overview
- TMP-112 is a temperature sensor.
- DATASHEET Link: http://www.ti.com/lit/ds/symlink/tmp112.pdf
What You Need / Links
- Arduino Nano
- I²C Shield for Arduino Nano
- USB Cable Type A to Micro Type B 6 Feet Long
- I²C Cable
- TMP112 I²C Temperature Sensor ±.5°C 12-Bit I²C Mini Module
Circuit Diagram
Programming
#include
void setup()
{
// I2C address of the TMP112
#define TMP_ADDR 0x48
// Join I2c Bus as master
Wire.begin();
// Start serial communication
Serial.begin(9600);
// Begin transmission
Wire.beginTransmission(TMP_ADDR);
// Select ENABLE register
Wire.write(0x01);
// Select normal operation
Wire.write(0x60A0);
// End transmission and release I2C bus
Wire.endTransmission();
}
void loop()
{
// Begin transmission
Wire.beginTransmission(TMP_ADDR);
// Select Data Registers
Wire.write(0X00);
// End Transmission
Wire.endTransmission();
delay(500);
// Request 2 bytes , Msb first
Wire.requestFrom(TMP_ADDR, 2 );
// Read the two bytes
while(Wire.available())
{
//remove garbage
Serial.flush();
int msb = Wire.read();
int lsb = Wire.read();
Wire.endTransmission();
// Data conversion in raw values
int rawtmp = msb << 8 |lsb;
int value = rawtmp >> 4;
double ans = value * 0.0625 ;
// Print output
Serial.print("celsius value : ");
Serial.println(ans) ;
}
}
I did my best u do yours ;-)
For further quires Feel free to visit our site: