TMP102 Digital Temperature Sensor Module (HCMODU0100)

Modules for various types of sensors including accelerometers. gyro's, IR motion, etc
Post Reply
admin
Site Admin
Posts: 880
Joined: Sun Aug 05, 2012 4:02 pm

TMP102 Digital Temperature Sensor Module (HCMODU0100)

Post by admin » Wed Jun 01, 2016 2:05 pm

Image




The TMP102 device is a digital temperature sensor ideal for NTC/PTC thermistor replacement where high accuracy is required. The device offers an accuracy
of ±0.5°C without requiring calibration or external component signal conditioning. Device temperature sensors are highly linear and do not require complex calculations or lookup tables to derive the temperature. The on-chip 12-bit ADC offers resolutions down to 0.0625°C. The module (HCMODU0100) provides header pins for power (3.3V), and to its digital I2C interface including bus pullup resistors.

PLEASE NOTE: This module does not include an on-board regulator. Do not power it above 3.6V otherwise you will cause permanent damage.

ImageImage


Features:

• Accuracy Without Calibration:
– 2.0°C (max) from –25°C to 85°C
– 3.0°C (max) from –40°C to 125°C
• Low Quiescent Current:
– 10-μA Active (max)
– 1-μA Shutdown (max)
• Supply Range: 1.4 to 3.6 V
• Resolution: 12 Bits
• Digital Output: I2C interface Compatibility


Image




Raspberry Pi users:

For Raspberry Pi uses we have tested this module with the free Cayenne cloud based IoT software platform. Simply connect the module to your Raspberry Pi as shown below and use the Cayenne software platform to get remote temperature readings without writing a single line of code.


Image

You can create a free account simply by clicking our referral link below:
                  • Image



Arduino users:

To use this module with your Arduino please see the following connection diagram and sketch:


Image


  1. /* FILE:    TMP102_Example.cpp
  2.    DATE:    01/06/16
  3.    VERSION: 0.1
  4.    AUTHOR:  Andrew Davies
  5.  
  6.    Library created by Hobby Components Ltd (HOBBYCOMPONENTS.COM)
  7.    
  8. 26/05/16 version 0.1: Original version
  9.  
  10.    
  11. This example sketch has been written to work with the TMP102 temperature sensor,
  12. and in particular the TMP102 digital temperature sensor module (HCMODU0100).
  13. The sketch will read the current temperature from the module and display it via
  14. the serial port. To connect the TMP102 to your Arduino connect it as follows:
  15.  
  16. Uno/Nano..........TMP102
  17. 3V3...............3V3
  18. GND...............GND
  19. SCL...............A5
  20. SDA...............A4
  21.  
  22.  
  23. You may copy, alter and reuse this code in any way you like, but please leave
  24. reference to HobbyComponents.com in your comments if you redistribute this code.
  25. This software may not be used directly for the purpose of selling products that
  26. directly compete with Hobby Components Ltd's own range of products.
  27.  
  28. THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
  29. EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  30. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
  31. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
  32. INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
  33. REASON WHATSOEVER.
  34. */
  35.  
  36. /* Include the wire library */
  37. #include <Wire.h>
  38.  
  39. /* The TMP102 can have one of 4 I2C address: 0x48 (ADD0 Pin -> GND),
  40.    0x48 (ADD0 Pin -> 3.3V), 0x4A  0x48 (ADD0 Pin -> SDA),
  41.    0x4B  0x48 (ADD0 Pin -> SCL). For HCMODU0100 module default is 0x48 */
  42. int I2CAdd = 0x48;
  43.  
  44.  
  45. void setup()
  46. {
  47.   /* Initialise the wire and serial port libraries */
  48.   Wire.begin();
  49.   Serial.begin(9600);
  50. }
  51.  
  52.  
  53. void loop()
  54. {
  55.   /* Get the current temperature and output it to the serial port */
  56.   Serial.println(GetTemp());
  57.  
  58.   /* Wait a second before doing it again */
  59.   delay(1000);
  60. }
  61.  
  62.  
  63.  
  64. /* Gets the current temperature via the I2C interface */
  65. float GetTemp()
  66. {
  67.   int Data;
  68.   /* Set the sensors address pointer to the 16bit temp register */
  69.   I2CWritePointer(0);
  70.   /* Result is in the most significant 12 bits so shift it down. */
  71.   Data = I2CReadInt() >> 4;
  72.  
  73.   /* Result is now in 12 bit two's compliment so convert it to 16bit
  74.    *  two's compliment */
  75.   if(Data & 0x0800)
  76.   {
  77.     Data += 0xF000;
  78.   }
  79.  
  80.   /* Result is now in 0.0625oC increments so adjust it for oC */  
  81.   return Data * 0.0625;
  82. }
  83.  
  84.  
  85. /* Read two bytes from the sensors I2C interface and return it as a 16bit integer */
  86. unsigned int I2CReadInt()
  87. {
  88.   unsigned int Data;
  89.  
  90.   Wire.requestFrom(I2CAdd, 2);
  91.   Data = Wire.read() << 8;
  92.   Data += Wire.read();
  93.   Wire.endTransmission();
  94.  
  95.   return Data;
  96. }
  97.  
  98.  
  99. /* Writes to the sensors address pointer register */
  100. void I2CWritePointer(byte Register)
  101. {
  102.   Wire.beginTransmission(I2CAdd);
  103.   Wire.write(Register);
  104.   Wire.endTransmission(true);
  105. }



Image
tmp102.pdf


Disclaimer: The Cayenne platform is an external free service and is not provided by, or connected to, Hobby Components Ltd. It is therefore not being sold as part of the product advertised on this page. As such we do not provide any guarantees or warranties with regards to this service. Issues or questions related to the Cayenne platform should be directed to Cayenne and not Hobby Components Ltd.

Libraries, example code, and diagrams are provided as an additional free courtesy by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.
You do not have the required permissions to view the files attached to this post.

RMurphy195
Posts: 8
Joined: Fri Oct 21, 2022 3:16 pm

Re: TMP102 Digital Temperature Sensor Module (HCMODU0100)

Post by RMurphy195 » Fri Dec 23, 2022 11:29 am

Hi there -
Initially I coud only get a reading of 0.00 as the temperature using the sample sketch provided.

However I discovered that the call to the routine I2CReadInt() was commented out, so I changed the following piece of code (lines 65 - on) to readas follows (change is in bold, the comment terminator added).

float GetTemp()
{
int Data;
/* Set the sensors address pointer to the 16bit temp register */
I2CWritePointer(0);
/* Result is in the most significant 12 bits so shift it down. */
Data = I2CReadInt() >> 4;

/* Result is now in 12 bit two's compliment so convert it to 16bit
* two's compliment */
if(Data & 0x0800)
{
Data += 0xF000;
}

/* Result is now in 0.0625oC increments so adjust it for oC */
return Data * 0.0625;
}


Seems to work OK now

I hope this helps - Richard

andrew
Site Admin
Posts: 1427
Joined: Sun Aug 05, 2012 4:15 pm

Re: TMP102 Digital Temperature Sensor Module (HCMODU0100)

Post by andrew » Mon Dec 26, 2022 8:44 am

Thanks for pointing this out. It looks like the closing */ on the previous line got accidently removed for some reason. I've now corrected the sketch in the first post.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

RMurphy195
Posts: 8
Joined: Fri Oct 21, 2022 3:16 pm

Re: TMP102 Digital Temperature Sensor Module (HCMODU0100)

Post by RMurphy195 » Tue Jan 31, 2023 10:32 pm

A bit of further work on this one - trying to get a temperature logger to work, I found that polling at regular intervals gave the same temperature every time, even if I breathed on the sensor to heat it up. After a bit of head-scratching (and a trial of the Sparkfun example sketch) I found that the sensor performs better if you put it to sleep after every reading, and wake it up again for the next one.
Cheers - Richard

PS the drawing above semms to show a connection to the Arduino 5v output instead of the 3.3v one!

andrew
Site Admin
Posts: 1427
Joined: Sun Aug 05, 2012 4:15 pm

Re: TMP102 Digital Temperature Sensor Module (HCMODU0100)

Post by andrew » Wed Feb 01, 2023 5:19 pm

PS the drawing above semms to show a connection to the Arduino 5v output instead of the 3.3v one!
Thanks for pointing this out, I'll get it corrected ASAP
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “Sensors”