3 Replies Latest reply on Feb 20, 2018 1:28 AM by rozoa_bd_2512216

    Intergrating a LIDAR (VL53L0X) over I2C


      Hi Forum




      As part of my project I would like to be able to read the output of a LIDAR sensor on a serial monitor over the I2C bus, using a PSoC 5LP. (Linked below)


      http://www.st.com/content/ccc/resource/technical/document/datasheet/group3/b2/1e/33/77/c6/92/47/6b/DM00279086/files/DM00279086.pdf/jcr:content/translations/en.DM00279086.pdf (LIDAR datasheet)


      I found a post that took the ardunio libraries and converted them to PSoC 4 libraries. (Linked below)




      I have the serial monitor part working however I cannot get the sensor to initiate. I had an printf after the initialization of each component (Timer and I2C block) showing the place where the program hangs. (picture attached)


      Any help on whether this is a bug in my code or a hardware issue would be greatly appreciated.


      Below is attached my workspace archive (Minimal) and an image of what is displayed in PuTTy



        • 1. Re: Intergrating a LIDAR (VL53L0X) over I2C

          Welcome in the forum.


          Byte I2C interface is quite simple: After setting up the component and starting it you use


              I2C_MasterSendStart(DeviceAddress,I2C_WRITE_XFER_MODE);    // Initialize a transaction for writing
              I2C_MasterWriteByte(Register);                // Indicate which register you want to write to
              I2C_MasterWriteByte(Value);                // Write to register
              I2C_MasterSendStop();                    // End of transaction


          When you want to read from a device you use (example for reading two bytes


              I2C_MasterSendStart(DeviceAddress,I2C_WRITE_XFER_MODE);    // Initialize a transaction for writing
              I2C_MasterWrite(Register);                // Indicate which register you want to write to
              I2C_MasterReadByte(I2C_ACK_DATA);            // Read from register
              I2C_MasterReadByte(I2C_NAK_DATA);            // Read from register, last byte is NAKed
              I2C_MasterSendStop();                    // End of transaction


          Not too difficult. Keep in mind that most of the APIs (except those for reading a byte) return a status byte which, when non-zero indicate an error condition.


          The high-level APIs must be used in this way:


          Writing to slave Count bytes


          Reading from Slave sending register/command byte first:



          • 2. Re: Intergrating a LIDAR (VL53L0X) over I2C



            Thanks for the quick reply, will try out what you suggested 





            • 3. Re: Intergrating a LIDAR (VL53L0X) over I2C

              Hi Forum,

              I am working on this project and try to change my sensor address but i cant change it, because i need to connect another sensor in same I2C bus, so i need to change the default address 0x29.

              I am using the same code from the link


              Measuring distance with VL53L0X ToF sensor - Hackster.io

              any one can help me to understand how i will change my sensor default address ? I already try to reach out my sensor forum POLOlU , but they reply me they reply me this (we are not familiar enough with your microcontroller platform to offer detailed advice about working with it. )


              Thanks for your cooperation,

              Md. Asif Reza.