trouble interfacing TPA81 thermopile array

I’m trying to interface Devantech’s TPA81 8 pixel thermopile sensor to the Arduino, and I’m having no luck. This is my first attempt to use I2C, so it’s possible I’m making a mistake, but I’ve replicated Tom Igoe’s code for interfacing their CMPS03 compass, with no luck.

The code runs, but my output is “0 1 2 3 4 5 6 7 8 9”, the register number I’m trying to read (and the byte I just send the I2C device).

Here’s the

// prototype code for interfacing Devantech TPA81 thermopile array
// http://www.robot-electronics.co.uk/htm/tpa81tech.htm

#include <Wire.h>
#define TPA81ADDR 0xd0

void setup() 
{ 
  Wire.begin();
  Serial.begin(9600);
} 
 
void loop() 
{
  byte b;
  int i;
  
  for (i=0; i<=9; i++)
  {
    Wire.beginTransmission(TPA81ADDR);
    Wire.send(i);
    Wire.endTransmission();
    
    Wire.requestFrom(TPA81ADDR, (int) 1);
 
   while(Wire.available() < 1)
   { ; }

    b = Wire.receive();

    Serial.print(b, DEC);
    Serial.print(" ");
  }
  Serial.println("");
 
  delay(2000); 
}

This may or may not be related, but when I switch between the mega8 and 168, I get these errors:

In file included from /Applications/arduino-0008/lib/targets/arduino/WProgram.h:5,
                 from Stepper.cpp:48:
/Applications/arduino-0008/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/avr/signal.h:36:2: warning: #warning "This header file is obsolete.  Use <avr/interrupt.h>."
In file included from /Applications/arduino-0008/lib/targets/arduino/WProgram.h:7,
                 from Stepper.cpp:48:
/Applications/arduino-0008/lib/targets/arduino/wiring.h:60:1: warning: "abs" redefined
In file included from /Applications/arduino-0008/lib/targets/arduino/WProgram.h:1,
                 from Stepper.cpp:48:
/Applications/arduino-0008/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/stdlib.h:116:1: warning: this is the location of the previous definition
In file included from utility/twi.c:25:
/Applications/arduino-0008/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/avr/signal.h:36:2: warning: #warning "This header file is obsolete.  Use <avr/interrupt.h>."

help?

-j

found it! the address listed by the vendor was in already-shifted form (due to I2C addressing). I right-shifted the address one bit (i.e. address should be 0x68 not 0xd0) and it's working as expected.

-j

Hi,

Iv been trying to get the TPA81 working with your code but with little luck. I have you code with the altered address as mentioned in your second post. 5v in, tx pin one goes to SDA, and rx goes to SDL. I have pull up resistors on these lines. Any ideas what I might be doing wrong?

Thanks.

Sorry, but that code, with the address change noted, works for me. Below is some code that I use to test a set of 4 (after appropriate address changes).

The ATmega has internal pullups - I found that my circuit works just fine with and without external pullups.

-j

// prototype code for interfacing Devantech TPA81 thermopile array
// http://www.robot-electronics.co.uk/htm/tpa81tech.htm
//
// Jason Winningham
// 27 june 2007

#include <Wire.h>
#define NUM_SENSORS 4
byte sensor_address[] = { 0xd0, 0xd2, 0xd4, 0xd6 };

void setup() 
{ 
  Wire.begin();        // join i2c bus (address optional for master) 
  Serial.begin(9600);  // start serial for output 
  Serial.print("starting TPA81 bus probe\n");
} 
 
void loop() 
{
  byte b, s;
  int i;
  
  for (s=0; s < NUM_SENSORS; s++)
  {
    Serial.print(sensor_address[s], HEX);
    Serial.print(": ");
    for (i=1; i<=9; i++)
  {
    Wire.beginTransmission(sensor_address[s]>>1);
    Wire.send(i);
    Wire.endTransmission();
    
    Wire.requestFrom(sensor_address[s]>>1, (int) 1);
 
   while(Wire.available() < 1)
   { ; }

    b = Wire.receive(); // receive a byte as character 

    Serial.print(b, DEC);
    Serial.print(" ");
  }
  }
  Serial.println("");
 
  delay(2000); 
}

it works! i was using TX pin one and RX pin 0 not analog pin 4 and analog pin 5! its always a stupid mistake!