Hello guys,
I need you help. I am using the i2c_t3 library on the Teensy 3.1 to talk to my MLX90614 temperature sensor.
On the normal I2C pins (18 & 19), it does work without any problem. But as those are needed for the UTFT library, I was forced to switched to 29 & 30.
SDA is connected to 30, SCL to 29.
However, the sensor gives me no output on those two. What I did on software side is to change the pins inside the constructor from "I2C_PINS_18_19" to "I2C_PINS_29_30"
and replace "Wire" with "Wire1". Here is the code (which worked fine with pins 18 and 19):
Have I missed something ? Maybe I must change some port registers to activate I2C on 29 & 30 ?
Thanks a lot for your help
I need you help. I am using the i2c_t3 library on the Teensy 3.1 to talk to my MLX90614 temperature sensor.
On the normal I2C pins (18 & 19), it does work without any problem. But as those are needed for the UTFT library, I was forced to switched to 29 & 30.
SDA is connected to 30, SCL to 29.
However, the sensor gives me no output on those two. What I did on software side is to change the pins inside the constructor from "I2C_PINS_18_19" to "I2C_PINS_29_30"
and replace "Wire" with "Wire1". Here is the code (which worked fine with pins 18 and 19):
Code:
#include "MLX90614.h"
void MLX90614::initialise() {
Wire1.begin(I2C_MASTER, 0x00, I2C_PINS_29_30, I2C_PULLUP_INT, I2C_RATE_100);
delay(5);
temperature = 0;
ambient = 0;
}
void MLX90614::measure(int TaTo) {
int rawData = getRawData(TaTo);
double tempData = (rawData * 0.02) - 0.01;
tempData -= 273.15;
if (TaTo)
ambient = (float) tempData;
else
temperature = (float) tempData;
}
int MLX90614::getRawData(int TaTo) {
// Store the two relevant bytes of data for temperature
byte dataLow = 0x00;
byte dataHigh = 0x00;
Wire1.beginTransmission(0x5A);
if (TaTo)
Wire1.send(0x06); //measure ambient temp
else
Wire1.send(0x07); // measure objec temp
Wire1.endTransmission(I2C_NOSTOP);
Wire1.requestFrom(0x5A, 2);
dataLow = Wire1.read();
dataHigh = Wire1.read();
Wire1.endTransmission();
int tempData = (((dataHigh & 0x007F) << 8) + dataLow);
return tempData;
}
float MLX90614::getAmbient() {
measure(1);
return ambient;
}
float MLX90614::getTemperature() {
measure(0);
return temperature;
}
Have I missed something ? Maybe I must change some port registers to activate I2C on 29 & 30 ?
Thanks a lot for your help