Community
cancel
Showing results for 
Search instead for 
Did you mean: 
TChoi4
Beginner
1,569 Views

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

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.

4 Replies
idata
Community Manager
129 Views

Hi,

 

 

Take a look at http://iotdk.intel.com/docs/master/upm/modules.html http://iotdk.intel.com/docs/master/upm/modules.html . This is a list of the supported sensors by the UPM libraries. I searched for the mlx90615 but couldn't find it, only the MLX90614. This may be the reason why you're seeing issues with this sensor and not with the other even though the code is correct. Have you tried your code on a different sensor that's supported in the UPM library?

 

 

Also, what image version and UPM version are you suing?

 

 

Sergio

 

idata
Community Manager
129 Views

Do you still need help with this thread, were you able to work with the mlx90615?

 

 

Sergio

 

GGera4
New Contributor I
129 Views

Hi,

I guess from What I have read https://github.com/Seeed-Studio/Digital_Infrared_Temperature_Sensor_MLX90615/commit/ea7a90b4d1240398... here that you are facing the same problem as many of us, "repeated start" is not supported in mraaa.... sajin has released a simple one https://github.com/sajingeo/i2crw https://github.com/sajingeo/i2crw but I have not been able to use it or push it in mraa. i f you understand his proposal and make some progress please let- me know.

best regards

idata
Community Manager
129 Views

What have you tried so far in trying to make sajin's approach work? Have you made any progress so far?

 

I checked https://github.com/sajingeo/i2crw https://github.com/sajingeo/i2crw and noticed it only has a .c and a .h file. In order to use these files they need to be in the proper folder. The libraries should be stored in the /usr/include or /usr/include/i2crw folder.

 

 

Sergio

 

Reply