Communicating to I2C sensor with arduino

Hi, I am new to the I2C protocol and am wondering how I could communicate with an Arduino to this sensor: https://www.vishay.com/docs/84968/veml3328.pdf on an Arduino Uno. Thanks for any help.

Literally, google "VEML3328 Arduino". For me, what you want is the FIRST LINK.
Forum helps best those who try to help themselves. Have a read:
How to get the best from this forum

1 Like

I suggest you go through some tutorials on I2C and basic Arduino programing. Once you get through that you should be able to ask a more detailed question. Also realize there is more then one Arduino operating on different voltages and also different processors on them, so the choice is critical to be able to give you an answer.

1. It is a 3.3V sensor. So, collect a level shifter (Fig-1) and connect the sensor with UNO via the level shifter.
levelShifter
Fig-1:

2. Upload the following sketch (untested) and check that the Serial Monitor shows 28 (28 h = the ID of the device).

void setup()
{
    Serial.begin(9600);
    Wire.beginTransmission(0x10);    //lsveAddress = 0010000
    Wire.write(0x0C);  //command code before reading ID
    byte busStatus = Wire.endTransmission();
    if(busStaus != 0)
    {
         Serial.print("Sensor is not found.");
         while(1);  //wait for ever
    }
    Serial.println("Sensor is found");
   //-------------------------------------------
    Wire.requestFrom(0x10, 2);  //requesting for 2-bytes
    Serial.println(Wire.read(), HEX); //should show: 28, the Device ID
}

void loop()
{

}

Interesting. I Have been able to detect the device without a logic level converter, using the basic I2C scanner example, but I will try with a logic level converter.

If you are using 5V UNO, then do not connect your 3.3V sensor next time with UNO. You might come up with a fried sensor.

Set up circuit so that SDA and SCL were going through logic level converter, and your sketch detected the sensor once I added Wire.Begin(); The response I got was FF.

Guide This might be helpful; at the very bottom I found a basic program to communicate to the sensor. What I am not sure of is what the Wire library is sending exactly when I use the beginTransmission and endTransmission. I have looked in the Arduino reference but haven't found this information...

Did you see this library?
https://github.com/DevelopiumTech/VEML3328

1 Like

Thank you so much! This will be a big help. I didn't think they had a library yet for this sensor. It works really well! This is a life saver. I was about to try writing a custom library so I could have more control of the I2C communication, but this handles that for me.

Well, if you read reply 2, the answer was there, but hey...

If I would have the sensor, I would certainly investigate why the sketch of post #4 is not acquiring the device ID?

Sorry about that, I somehow over read that. ):

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.