4 Replies Latest reply on Mar 31, 2016 3:56 PM by Intel Corporation

    edison i2c problem - i can read i2c data by i2cdump, but i can't read i2c data by mraa library

    ThomasAquinasC.

      Hi.

      This is Thomas Aquinas Choi.

       

      I'd like to monitering temperature with my edison board and mini breakout board and mlx90615(not mlx90614) and mraa library ver 0.9.0.

      So, I connected these things and check by i2cdump command.

      I could read i2c data by i2cdump command and I could read change of temperature data by use i2cdump command twice.

      (I thought this means my circuit and sensor and edison board work well.)

       

      And I coded c++ program to read i2c data but It doesn't work.

      I could see only FFFF for every register.

      (Fortunatly, there's no error when open or write or read i2c port.)

      I thought that It could be the problem of my program, so I checked my program with another i2c sensor MPU6050.

      (Of course, I modify device addr, register addr, protocol for MPU6050)

      At this time, my program works!

       

      This is main function of my MLX90615 I2C read program.

       

      int main()

      {

         uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];

       

         mraa::I2c* i2c;

         i2c = new mraa::I2c(1);

       

         i2c->frequency(mraa::I2C_STD);//maximum sclk of MLX90615 is 100kHz

       

        for (;;)

        {

          i2c->address(0x5B);

          i2c->writeByte(0x27);//register addr of temp obj

       

          i2c->address(0x5B);

          i2c->read(rx_tx_buf, 3);//high, low, pec

       

          printf("%2x%2x\n", rx_tx_buf[1], rx_tx_buf[0]);

       

          usleep(100000);

        }

       

        delete i2c;

       

        return MRAA_SUCCESS;

      }

       

      The result of this program was always FFFF.

       

      And this is main function of my MPU6050 I2C read program.

       

      int main()

      {

        uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];

       

        mraa::I2c* i2c;

        i2c = new mraa:I2c(1);

       

        i2c->address(0x68);

        rx_tx_buf[0] = 0x6B;//sleep configre register addr

        rx_tx_buf[1] = 0x00;//wake up command. default value is 0x40

        i2c->write(rx_tx_buf, 2);

       

        for (;;)

        {

          i2c->address(0x68);

          i2c->writeByte(0x3B);//register addr of x-axis acc

       

          i2c->address(0x68);

          i2c->read(rx_tx_buf, 2);

       

          printf("%2x%2x\n", rx_tx_buf[1], rx_tx_buf[0]);

       

          usleep(100000);

        }

       

        delete i2c;

       

        return MRAA_SUCCESS;

      }

       

      The result of this program was changing when I swing MPU6050 sensor.

      Plus, I could read MPU6050 i2c data by i2cdump command, too.

       

      I don't know what is the difference of i2cdump command and mraa i2c library.

      Please help me.