I2C communication problem with a light sensor.

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

cross mob
Anonymous
Not applicable

Dear all,

   

I'm new on PSoC and I got a problem of communication between a light sensor TSL2561 and my PSoC 5

   

(here the doc of the sensor : https://cdn-shop.adafruit.com/datasheets/TSL25911_Datasheet_EN_v1.pdf )

   

I can see the buffer on the debug mode but theres are empty, and my sensor don't write his data inside. The datasheet of the sensor talk about perform a four-byte I2C read operation using the auto-increment in the page 17, but I don't understand what is this.

   

 

   

My code :

   

#include <project.h>

   

#define TSL_ADDR    0x29

   

int main()
{
    CyGlobalIntEnable; 
    uint8 mwbuff1[7];
    I2C_Start();

   

    for(;;)
    {
        I2C_MasterReadBuf(TSL_ADDR,mwbuff1,7,I2C_MODE_COMPLETE_XFER);

   

        CyDelay(500);
    }
    I2C_Stop();
}

   

 

   

So what I have to add in my code, for read the light sensor's data.

   

 

   

Thanks.

   

Jacque

0 Likes
6 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Did you add the Pull up resistors to your I2C lines.  Please post your code so we can check it.

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Check out this example it has a PDF that explains it.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thanks bobgoar,

   

Yes I have put the pull up resistor.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Look into datasheet how the scl pin should be configured: Open drain, drives low.

   

Keep in mind that the APIs return a status byte which, when non-zero indicate an error condition.

   

 

   

Bob

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

What version of Psoc Creator are you running? Please upgrade to 4.1.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Creator 4.1 ??? Where did you get it from? I am running on Creator 4.0 SP1

   

 

   

Bob

0 Likes