Go Down

Topic: Strange Problems with IRsensor. (Read 341 times) previous topic - next topic

kami83

Hi,

i am using a Zytemp TN168
(http://www.zytemp.com/products/tn168.asp). As shown on the Picture i connected it to a Mega 2560 Arduino Board. i used this new libs:

https://github.com/freetronics/IRTemp

to read out the 3 data pins.

At the first time everything works fine.I uploaded this code:

Code: [Select]
/*

    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 */

#include "IRTemp.h"

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 TempUnit SCALE=CELSIUS; // Options are CELSIUS, FAHRENHEIT

IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);

void setup(void) {
Serial.begin(9600);
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 == FAHRENHEIT ? " F" : " C");
}
}


After this i get good values from the sensor.

But if i disconnect the Board from the USB i always get FAILURE.
The only way to repair it is, to change all pins for example to 7,8,9 than i upload the data and the Controller is working. but if i disconnect USB i get the same problem.
If i only reset the Board. There is no Problem. Only the Power Up makes this problem.
Here is a picture of my Wiring:

http://picpaste.com/Foto-navNvrWt.JPG

Please help me.

cu kami83

Go Up