IR Sensor

Our range of tiny modules are designed to make it easy for you to quickly add functionality to your projects. [Module List]
Post Reply
Posts: 1
Joined: Tue Oct 16, 2012 7:55 am

IR Sensor

Post by cpoole » Sun Nov 04, 2012 5:14 am

Hi all,
Has anyone connected the new IR Temp Sensor and got it to spit out correct readings? I tried the example sketch the other day and it printed out 'failure'. I am new to arduino and programming, so i am not very skilled at troubleshooting 'c' programs yet. Can anyone help?

Posts: 63
Joined: Fri Sep 21, 2012 7:22 am

Re: IR Sensor

Post by csconsulting » Mon Nov 05, 2012 9:13 am

Can you post your sketch for us?

You did download the library did you?

Did the program actually compile and upload to the arduino? or did it fail before that stage.

Posts: 3
Joined: Tue Apr 30, 2013 5:51 am

Re: IR Sensor

Post by gth » Fri May 03, 2013 6:03 am

I'm not getting what I'd expect from the sample code - just the "Failed" print out from the print temperature function. I have the IRTemp library installed and it compiles and uploads without any issues.

I'll see if I can troubleshoot further, but figured it'd be worth posting.

Code: Select all

#include <IRTemp.h>

 * File:    readTemperature.ino
 * Version: 1.0
 * Author:  Andy Gelme (@geekscape)
 * License: GPLv3
 * For more information see
 * IRTemp library uses an Arduino interrupt:
 *   If PIN_CLOCK = 2, then Arduino interrupt 0 is used
 *   If PIN_CLOCK = 3, then Arduino interrupt 1 is used

static const byte PIN_DATA    = 2;
static const byte PIN_CLOCK   = 3;  // Must be either pin 2 or pin 3
static const byte PIN_ACQUIRE = 4;

static const bool SCALE=false;  // Celcius: false, Farenheit: true


void setup(void) {
  Serial.println("IRTemp example");

void loop(void) {
  float irTemperature = irTemp.getIRTemperature(SCALE);
  printTemperature("IR", irTemperature);

  float ambientTemperature = irTemp.getAmbientTemperature(SCALE);
  printTemperature("Ambient", ambientTemperature);


void printTemperature(
  char  *type,
  float  temperature) {

  Serial.print(" temperature: ");

  if (isnan(temperature)) {
  else {
    Serial.println(SCALE  ?  " F"  :  " C");

Posts: 73
Joined: Sat Jul 27, 2013 6:08 pm

Re: IR Sensor

Post by charlest » Sat Sep 07, 2013 7:52 pm

tronixstuff wrote: How have you connected the wires from your board to the IRTEMP? A popular option is to solder male header pins as such:
and then run male-female jumpers back to the board.
Hi, while I'm reading up on the IRTEMP module, I came across this thread & your posted picture. I noticed the male header pins are bended around 90 degrees. I was wondering how did you bend those pins?

Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia

Re: IR Sensor

Post by andrew » Sun Sep 08, 2013 1:04 am

You can buy them like that, for example ... ight-angle

Posts: 73
Joined: Sat Jul 27, 2013 6:08 pm

Re: IR Sensor

Post by charlest » Sun Sep 08, 2013 9:09 am

Thanks for your reply & link.

Post Reply