cancel
Showing results for 
Search instead for 
Did you mean: 

SHTC3 sensor ( temperature and humidity ) driver problem with I2C

Zedestrian
Associate II

Hello everybody,

I'm working on implementing the driver of shtc3 sensor ( temperature and humidity sensor) with an stm32L152xx microcontroller. I'm using the code example provided by the manufacturer( https://github.com/Sensirion/shtc3-stm-sample-project/tree/master/Source ) but, I replaced I2C functions with HAL functions provided by ST. However, there are some I2C write fucntions into some registers without the data to write which confuses me and I'm not able to make it work or just read the sensor id. Any suggestions or clarifications is more than welcome.

Thanks in advance !

7 REPLIES 7
TDK
Guru

Perhaps use HAL_I2C_Mem_Write/HAL_I2C_Mem_Read if you are interfacing with registers on the chip.

If you feel a post has answered your question, please click "Accept as Solution".

I tried these functions but it fails. In addition, to use these functions especially "HAL_I2C_Mem_Write" I need to specify the values to write into the registers which I don't find in SHTC3 datasheet (the values to write into the registers)

TDK
Guru

The datasheet explains how to communicate with the chip in "5 Operation and Communication".

https://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/2_Humidity_Sensors/Datasheets/Sensirion_Humidity_Sensors_SHTC3_Datasheet.pdf

If you feel a post has answered your question, please click "Accept as Solution".

0693W00000DlgkbQAB.jpgI understand what you're saying, I saw it. However, in the folowing picture I don't know what to put in the place of parameter P which is the data to bewritten into the wakeup register

TDK
Guru

P is the I2C stop condition. There are only 3 transaction bytes in the screenshot you posted. After the stop condition, you must wait the SHTC3 wake up time per the table before sending the next command (measurement).

If you feel a post has answered your question, please click "Accept as Solution".

Ok, I see. Thanks for your help !

Zedestrian
Associate II

Just One last question. You have suggested to use HAL_I2C_Mem_Write/HAL_I2C_Mem_Read. But in order to use these function I need the values to write into the register or I just make a null pointer as a parameter or what ?