Go Down

Topic: D6T 4x4 sensor & I2C (Read 935 times) previous topic - next topic

selim

I have been trying to get my Omron D6T-44L-06 temperature sensor working on my Due for a while now. Something is wrong with the Due's I2C.  I have tried the fix from the Wire library on the Arduino GitHub, and that didn't work either.
I'm using this code to test it. It works perfectly and prints 16 accurate temperature readings as soon as I plug it in. But when I do the same for the Due, it doesn't work and there is no output to the serial monitor.
Code: [Select]
#include <Wire.h>

 
void setup()
 
{
 
  Wire.begin();                // join i2c bus (address optional for master)
 
  Serial.begin(9600);          // start serial communication at 9600bps
 
}
 
 
 
int reading = 0;
 
int count=0;
 
char buf[3];
 
 
 
void loop()
 
{
 
  // step 3: instruct sensor to return a particular echo reading
 
  Wire.beginTransmission(0x0a);
 
  Wire.write(byte(0x4c));      // sets register pointer to echo #1 register (0x02)
 
  Wire.endTransmission(false);      // stop transmitting
 
  // step 4: request reading from sensor
 
//Wire.requestFrom(0x0a, 32, byte(0x4c), 1);    // A line of code from a wire lib fix that didn't work. At this point, I am not using the
 
 
 
  // step 5: receive reading from sensor
 
  count=0;
 
  while(count<32)
 
  {
 
  if(2 <= Wire.available())    // if two bytes were received
 
  {
 
    reading = Wire.read();  // receive high byte (overwrites previous reading)
 
    reading+= Wire.read()<<8;
 
    Serial.print(reading / 10);   // print the reading
 
    Serial.print(" ");
 
    count+=2;
 
  }
 
  }
  //while(Wire.available()<1);
  //reading = Wire.read();
 
  Serial.println();
 
}

caltain

Maybe I'm just being slow today, but I don't get what you mean when you say you're using the posted code to test it, which works, but you try it on the Due and it doesn't work.  What are you using to test the D6T other than the Due?

If you are using a different Arduino board, remember that the Due uses a different processor and necessarily takes a different path to booting. That would impact all sorts of things.  Try dropping a quarter to half second delay at the end of the setup() and see if you don't have some better results. That's the best I can do without a better understanding of what you are using that worked and didn't.

Hope it helps!

Cheers!
caltain

ytemelli

void setup() {
 pinMode(SDA,INPUT_PULLUP);
 pinMode(SCL,INPUT_PULLUP);

Go Up