Saturday, September 12, 2015

Infra Red Contactless Temperature Sensor

We have a Contactless Thermometer at work. Just aim the little red dot at what ever you want to read, and the temperature displays on the LCD screen. I must be related to Rube Goldberg somewhere in my family tree, because my philosophy is why buy when you can build, even though I have to buy some parts. It's more satisfying when you construct something yourself, and know how it works.

This could be used in a security system, to detect a IR heat source, like fire, or people / animal presence.

I ordered a $10 TMP006 IR Sensor from Adafruit. Found out later they have a TMP007 which is supposed to be a little better. Anyway, the TMP006 uses 4 wires to connect, +5v, Gnd, SCL (pin A5), and SDA (pin A4).

The tutorial on the Adafruit site misses a step, and adds a GITHUB error. To begin, you will need to download two libraries from GITHUB. and

As usual, GITHUB adds a -master to the download, so you can't use the Arduino IDE import library menu option. You need to download both zip files, extract them,and then rename the folders by removing the -master. Then you need to copy both folders into your libraries folder. Now you can run the example sketch found on your Examples - Adafruit_TMP006 menu.

As the default is Celsius, and I prefer Fahrenheit, I have added a Celsius to Fahrenheit conversion line in two places.

Now I just have to add red LED "laser" pointer for aiming.

  This is an example for the TMP006 Barometric Pressure & Temp Sensor

  Designed specifically to work with the Adafruit TMP006 Breakout 

  These displays use I2C to communicate, 2 pins are required to  
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_TMP006.h"

// Connect VCC to +3V (its a quieter supply than the 5V supply on an Arduino
// Gnd -> Gnd
// SCL connects to the I2C clock pin. On newer boards this is labeled with SCL
// otherwise, on the Uno, this is A5 on the Mega it is 21 and on the Leonardo/Micro digital 3
// SDA connects to the I2C data pin. On newer boards this is labeled with SDA
// otherwise, on the Uno, this is A4 on the Mega it is 20 and on the Leonardo/Micro digital 2

Adafruit_TMP006 tmp006;
//Adafruit_TMP006 tmp006(0x41);  // start with a diferent i2c address!

void setup() { 
  Serial.println("Adafruit TMP006 example");

  // you can also use tmp006.begin(TMP006_CFG_1SAMPLE) or 2SAMPLE/4SAMPLE/8SAMPLE to have
  // lower precision, higher rate sampling. default is TMP006_CFG_16SAMPLE which takes
  // 4 seconds per reading (16 samples)
  if (! tmp006.begin()) {
    Serial.println("No sensor found");
    while (1);

  Serial.println("Send s to enter sleep mode, or w to wake up.  Measurements are not updated while asleep!");

void loop() {
  // Check for sleep/wake command.
  while (Serial.available() > 0) {
    char c =;
    if (c == 'w') {
      Serial.println("Waking up!");
    else if (c == 's') {
      Serial.println("Going to sleep!");

  // Grab temperature measurements and print them.
  float objt = tmp006.readObjTempC();
  objt = (objt * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
  Serial.print("Object Temperature: "); Serial.print(objt); Serial.println("*F");
  float diet = tmp006.readDieTempC();
  diet = (diet * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
  Serial.print("Die Temperature: "); Serial.print(diet); Serial.println("*F");
  delay(4000); // 4 seconds per reading for 16 samples per reading