I have this D6T Omron temperature sensor (1x8 array) and trying to get temperature readings from it. However, after debugging and making sure there's no error, I can't get anything outputted but simply 0's. Here's the code, basically modified from an example that is contained in the SoftI2CMaster library from github, more information here http://playground.arduino.cc/Main/SoftwareI2CLibrary
// Simple sketch to read out BMA020 using SoftI2C
// Readout BMA020 chip
// use low processor speed (you have to change the baud rate to 2400!)
// #define I2C_CPUFREQ (F_CPU/8)
#define NO_INTERRUPT 1
#define I2C_TIMEOUT 1000
#define SDA_PORT PORTC
#define SDA_PIN 4
#define SCL_PORT PORTC
#define SCL_PIN 5
#include <SoftI2CMaster.h>
#include <avr/io.h>
#define BMAADDR 0x14
float PTAT, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, PEC;
void CPUSlowDown(void) {
// slow down processor by a factor of 8
CLKPR = _BV(CLKPCE);
CLKPR = _BV(CLKPS1) | _BV(CLKPS0);
}
boolean setControlBits(uint8_t cntr)
{
Serial.println(F("Soft reset"));
if (!i2c_start(BMAADDR | I2C_WRITE)) {
Serial.println("failed at write start");
return false;
}
if (!i2c_write(0x4C)) {
Serial.println("failed at write");
return false;
}
i2c_stop();
return true;
}
boolean initBma(void)
{
if (!setControlBits(B00000010)) return false;;
delay(100);
return true;
}
int readOneVal(boolean last)
{
uint8_t msb, lsb;
lsb = i2c_read(false);
msb = i2c_read(last);
if (last) i2c_stop();
return (float)((msb<<8)|lsb)/64;
}
boolean readBma(void)
{
PTAT = 0xFFFF;
P0 = 0xFFFF;
P1 = 0xFFFF;
P2 = 0xFFFF;
P3 = 0xFFFF;
P4 = 0xFFFF;
P5 = 0xFFFF;
P6 = 0xFFFF;
P7 = 0xFFFF;
PEC= 0xFFFF;
if (!i2c_start(BMAADDR | I2C_WRITE)) return false;
if (!i2c_write(0x01)) return false;
if (!i2c_rep_start(BMAADDR | I2C_READ)) return false;
PTAT = readOneVal(false);
P0 = readOneVal(false);
P1 = readOneVal(false);
P2 = readOneVal(false);
P3 = readOneVal(false);
P4 = readOneVal(false);
P5 = readOneVal(false);
P6 = readOneVal(false);
P7 = readOneVal(false);
PEC = readOneVal(true);
return true;
}
//------------------------------------------------------------------------------
void setup(void) {
#if I2C_CPUFREQ == (F_CPU/8)
CPUSlowDown();
#endif
Serial.begin(19200); // in case of CPU slow down, change to baud rate / 8!
if (!initBma()) {
Serial.println(F("INIT ERROR"));
}
}
void loop(void){
if (!readBma()) Serial.println(F("READ ERROR"));
Serial.print(F("PTAT="));
Serial.println(PTAT);
Serial.print(F(" P0="));
Serial.println(P0);
Serial.print(F(" P1="));
Serial.println(P1);
Serial.print(F(" P2="));
Serial.println(P2);
Serial.print(F(" P3="));
Serial.println(P3);
Serial.print(F(" P4="));
Serial.println(P4);
Serial.print(F(" P5="));
Serial.println(P5);
Serial.print(F(" P6="));
Serial.println(P6);
Serial.print(F(" P7="));
Serial.println(P7);
Serial.print(F(" PEC="));
Serial.println(PEC);
delay(300);
}
Please any help would be appreciated :(