Announcements

Measure CO2 When It Matters - Infineon’s XENSIV™ PAS CO2 now comes in SparkFun Red. Check it now!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Bastienec
Level 1
Level 1
First reply posted First question asked Welcome!

Hello,

Discovering TLI493D-W2BW sensor with python and raspberry.

I managed to establish i2c communication and found the code.zip example,
But I'm having real troubles to read the temperature :
- the value seems awfully false,
- the value doesn't change with temperature changes.

In the file code.zip,
I tried to get the temperature with :

def update_data(self):
    global data
    (count, data) = self.pi.i2c_read_device(self.h, 6)

def get_temp (self)
    self.temp = (data[3] << 4) or (data [5] >> 4)

 

Does anybody see a mistake here ?

0 Likes
1 Solution
Sunil_P
Moderator
Moderator
Moderator
First question asked 100 replies posted 10 likes given

Hell @Bastienec.,

Sorry for the delayed response.  

I believe you have enabled the temperature measurement by setting the DT bit to 0 .
As you can see in the register summary, the temperature bits are located at 0x03H and 0x05H. Therefore, temperature data must be fetched from both the locations. That's what you're trying to do here with "(data[3] << 4) or ((data[5] >> 4 & 0x0C)". 

Sunil_0-1696827144357.png

Let me know if you have further specific question.

BR
Sunil.

 

 

 




View solution in original post

0 Likes
3 Replies
Bastienec
Level 1
Level 1
First reply posted First question asked Welcome!

I think I found the "offset" in the datasheet,
Now (almost there), I have :

def get_temp(self):
    selt.temp = (data[3] << 4) or ((data[5] >> 4 & 0x0C)                                                  //wondering if the "&0x0C" is necessary
    if selt.temp > 2047:
        self.temp -= 4096
    self.temp = (self.temp-1180)*0.24+25
    return self.temp

But I'm still wondering if I should fetch more bytes to read with
def update_data(self):
    global data
    (count, data) = self.pi.i2c_read_device(self.h, 10)            //instead of (count, data) = self.pi.i2c_read_device(self.h, 6)

0 Likes
Sunil_P
Moderator
Moderator
Moderator
First question asked 100 replies posted 10 likes given

Hell @Bastienec.,

Sorry for the delayed response.  

I believe you have enabled the temperature measurement by setting the DT bit to 0 .
As you can see in the register summary, the temperature bits are located at 0x03H and 0x05H. Therefore, temperature data must be fetched from both the locations. That's what you're trying to do here with "(data[3] << 4) or ((data[5] >> 4 & 0x0C)". 

Sunil_0-1696827144357.png

Let me know if you have further specific question.

BR
Sunil.

 

 

 




0 Likes
Sunil_P
Moderator
Moderator
Moderator
First question asked 100 replies posted 10 likes given

Hello @Bastienec ,

Let me know if you have further questions?   

BR
Sunil.

0 Likes