cancel
Showing results for 
Search instead for 
Did you mean: 

I2C issue with D6T-44L Omron, always return value 255

Zk47
Associate II

Hi everyone
I'm now using D6T-44L Omron sensor to measure Temparature, i read the User mannual as the below image.png

After that, i write my own code in IDE

Zk47_0-1710220330325.png

i use I2C_Scanner to check the device at which address is ready, here are my code and my result through UART to PC

Zk47_1-1710220433519.png

Zk47_2-1710220457971.png

It seems everything is okay but my return value is always 255

Zk47_3-1710220561080.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Thank for your reply,
I just found the solution
In HAL_I2C_Master_Transmit, i need to pass the address of the data command, because it is a pointer to data
so i need to modify the code like below 

Zk47_0-1710228269225.png

 

 

View solution in original post

3 REPLIES 3
urbito
Senior

Hello Zk47, 

 

I dont know if this is the case since i could not find any proper datasheet for your component, maybe you can share it. But sometimes, i2c devices have 2 address, one to read and one to write, for example:

#define EEPROM_ADDR_WR 0xA0
#define EEPROM_ADDR_RD 0xA1

 

i use these for an ee24lc512 eeprom, maybe it doesnt make any sense in your case, but just to let you know that.

 

Also, some othere devices need kind of initialization, in your code, you are only initializing the i2c driver in the MCU, but sometimes there are few commands to initialize/configure the device itself.

 

I can for example talk about the rc522, it needs couple of registers writes each time you power it up.

 

Hope it helps.

 

Greetings

Thank for your reply,
I just found the solution
In HAL_I2C_Master_Transmit, i need to pass the address of the data command, because it is a pointer to data
so i need to modify the code like below 

Zk47_0-1710228269225.png

 

 

padawan
Senior

Hi

some basic questions: The Pullup are done? The I²C speed is max 100kHz?

Basic2:

The STM HAL takes the "shifted" address for read and write.

So your read and write adress have to be the same (0x14) the read/wirte bit will be managed by the HAL_

in your scanner you make a shift in the device ready with "i" but yo display the teh unshifted "i"

So try Transmit with adrr = 0x14 and a receive with adrr = 0x14

 

hth

padawan