This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C command of OPT3001 [urgent]

Other Parts Discussed in Thread: OPT3001, TMP100

Dears,

Is there any sample code of OPT3001?

My customer test OPT3001 EVM and would like to implement OPT3001 on their system.

However, there is something wrong with the I2C read/write command.

They cannot get the ACK from OPT3001 and below are their I2C code and questions.

1.Do we need write configuration register at I2C initial section?

2.According the I2C example figure, is it still send 4 byte at send Address 00 for read result lux value?

 


Is there any problem with the code?

Thanks.

  • Hi Peter,

    Can you make sure if you have included sufficient code for an acknowledgment from OPT3001?

    I didn't get much information about OPT3001. But I'll try to help you here.

    I guess the sequence is like this:

    i2c_start();

    i2c_write(OPT3001_ID); //R/#W = 0; 0x88;

    // MCU waits for acknowledgement. This duration may be longer than a bit time

    i2c_write(Register); //0x00 // upon successful reception of ack. Remember that if MCU produces a stop command before OPT produces an ACK, OPT may assume it's a request for aborting the operation. I didn't get this info from OPT3001's technical manual, but from TMP100's manual.

    // Waits for Ack;

    i2c_start(); // Please note: no need to send a stop here, if you intend to read data from the last stored register.

    i2c_write(OPT_ID); //0x89 with R/#W = 1

    // waits for ack;

    i2c_read(bytes);

    i2c_stop(); // no need to wait for ack after receiving the last byte;

    I don't have a EVM with me. But this is a general format in I2C.

    I hope this will help you.

    Regards,

    Binoy Raphael.

  • Peter,

    You do need to write to the configuration register (0x01) first to get the data from the device.  You only have to write the configuration register once, not for every reading.  Here is what I use as a default to start converting:

    i2c write 0x88,0x01,0xC4,0x10

    (0x88 is the address, 0x01 is the register, 0xC4 and 0x10 are the data bytes)

    Then your code for data reading should work.

    Regards,

    Jason Bridgmon

  • Now adress is 0x44 if adress pin connected to GND.