Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 3.1: Problem using I2C on pins 29 & 30

  1. #1

    Teensy 3.1: Problem using I2C on pins 29 & 30

    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):

    #include "MLX90614.h"
    void MLX90614::initialise() {
    	Wire1.begin(I2C_MASTER, 0x00, I2C_PINS_29_30, I2C_PULLUP_INT, I2C_RATE_100);
    	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;
    		temperature = (float) tempData;
    int MLX90614::getRawData(int TaTo) {
    	// Store the two relevant bytes of data for temperature
    	byte dataLow = 0x00;
    	byte dataHigh = 0x00;
    	if (TaTo)
    		Wire1.send(0x06); //measure ambient temp
    		Wire1.send(0x07); // measure objec temp
    	Wire1.requestFrom(0x5A, 2);
    	dataLow =;
    	dataHigh =;
    	int tempData = (((dataHigh & 0x007F) << 8) + dataLow);
    	return tempData;
    float MLX90614::getAmbient() {
    	return ambient;
    float MLX90614::getTemperature() {
    	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

  2. #2
    Senior Member
    Join Date
    Nov 2012
    In theory (since I haven't tried it with these pins) you can do the same kind of thing to reassign these pins as was done for Serial2 pins 26 and 31 in your other post.
    In this case we want to reassign pins 29 and 30 to the I2C function which is ALT2. This info is in the table on page 64 of
      // reassign pins 29 and 30 to use the ALT2 configuration
      // which makes them  I2C pins - I2C1_SCL (pin29) and I2C1_SDA (pin30)
    This code should also be in setup().

    I hope this is right

  3. #3
    Solved the problem, thanks !

  4. #4
    Junior Member
    Join Date
    Jul 2016
    Hi, I'm also trying to get readings from the MLX90614 temperature sensor using pins 29 and 30. Would you be willing to share the code that you eventually used to get this to work?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts