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
cpoole
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?

csconsulting
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.

gth
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 www.freetronics.com/irtemp
 *
 * 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

IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);

void setup(void) {
  Serial.begin(38400);
  Serial.println("IRTemp example");
  Serial.println("~~~~~~~~~~~~~~");
}

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

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

  delay(1000);
}

void printTemperature(
  char  *type,
  float  temperature) {

  Serial.print(type);
  Serial.print(" temperature: ");

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

charlest
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:
Image
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?

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

Re: IR Sensor

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

You can buy them like that, for example
http://littlebirdelectronics.com/produc ... ight-angle

charlest
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