cancel
Showing results for 
Search instead for 
Did you mean: 

HTS221 Init and Deinit Sensor

ambinabhi
Associate II

I am working with HTS221 Humidity and Temperature sensor on STM32L4 IoT node eval board. So far its working fine as far as inint and read data apis are concerned. However i have couple of questions reagarding de_init (disable) the sensor i.e putting it in power down mode.

  1. Below is the code i am using to de_init the sensor
status_t de_init(int8_t DeviceAddr){
uint8_t tmp;
tmp = SENSOR_IO_Read(DeviceAddr, HTS221_CTRL_REG1);
/* HTS221 in power down */
tmp &= ~HTS221_PD_MASK;
 
/* ake HTS221 boot */
tmp &= ~HTS221_BOOT_BIT;
SENSOR_IO_Write(DeviceAddr, HTS221_CTRL_REG1, tmp);
}

After executing this i start getting constant temperature/humidity value whenever i read from sensor. I understood that the sensor is power down mode and receving last stored (before power down) values from control registerd. Do we need to clear the control registers as well ? How to do that. ?

2. Is there any way to only disable humidity or temperature alone. Currently If I put it in power down mode i cannot read either of the sensor values. Please correct me if my understanding is wrong, I am new to driver level programming.

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

Hi @ambinabhi​ , you have to set 0 in the PD bit of CTRL_REG1 (20h) to enter the PD mode, right? And you are getting wrong values after restarting the device (PD = 1)? When you restart the device, I suggest you also to set BDU 1, in order to avoid get false readings due to some kind of wrong initialization.

2. No, it is not possible to disable temperature or humidity selectively, because they come from the same internal dsp block, but you can of course read only the temperature or humidity output registers

Regards

View solution in original post

1 REPLY 1
Eleon BORLINI
ST Employee

Hi @ambinabhi​ , you have to set 0 in the PD bit of CTRL_REG1 (20h) to enter the PD mode, right? And you are getting wrong values after restarting the device (PD = 1)? When you restart the device, I suggest you also to set BDU 1, in order to avoid get false readings due to some kind of wrong initialization.

2. No, it is not possible to disable temperature or humidity selectively, because they come from the same internal dsp block, but you can of course read only the temperature or humidity output registers

Regards