VCNL36825T Initialisation

Hello together,

I am desperately trying to get the VCNL36825T sensor to work. Unfortunately without success.

To get a simple communication via I2C, I read the register 0xFA (ID_L and ID_H). Here I would expect the default value 0x26 to be returned. But the return value is 0x00.

#include <Wire.h>

byte b1;
byte b2;

void setup() {
Serial.begin(9600);
Wire.begin();
}

void loop() {
Wire.beginTransmission(0x60); // Sensor Address
Wire.write((byte)0xFA); // Register Address
Wire.endTransmission();

Wire.requestFrom(0x60, 2);
b1 = Wire.read();
b2 = Wire.read();
Serial.print(b1);
Serial.println(b2);
delay(1000);
}

With other I2C sensors the simple test works very well.

The main problem is that after every possible initialisation, no matter which one I have tried, the value for the measurement 0xF8 always results in 0.

Following MikroE's example, I tried the initialisation:

Registername: Comman Code, Low Byte, High Byte
Conf 1: 0x00, 0x00, 0x83
Conf 3: 0x04, 0x17, 0x08
Conf 2: 0x03, 0xCC, 0x00

But also here the response from the sensor remains 0.

According to the design requirements from VCNL36825T I tried to write the following registers:

Registername: Comman Code, Low Byte, High Byte
Conf 1: 0x00, 0x01, 0x00
Conf 2: 0x03, 0x00, 0x00
Conf 3: 0x04, 0x03, 0x00
Conf 1: 0x00, 0x03, 0x00 for PS_ON = 1
Conf 1: 0x00, 0x83, 0x02 for PS_ON = 1, PS_Init = 1
Conf 2: 0x03, 0x06, 0x00 for PS_ST = 1
Conf 3: 0x04, 0x0C, 0x7F

I used the Arduino Nano:

#include <Wire.h>

// I2C address of the VCNL36825T 0x60
#define Addr 0x60

unsigned int reading;

void setup()
{
  delay(500);
  // Initialise I2C communication as MASTER
  Wire.begin();
  // Initialise Serial Communication, set baud rate = 9600
  Serial.begin(9600);
  
  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  Wire.write(0x00); // 0x00 = config 1
  Wire.write(0x01); 
  Wire.write(0x00); 
  Wire.endTransmission();
  
  Wire.beginTransmission(Addr);
  Wire.write(0x03); // 0x03 = config 2
  Wire.write(0x00); 
  Wire.write(0x00);
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x04); // 0x00 = config 3
  Wire.write(0x00);
  Wire.write(0x00);
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x00); // 0x00 = config 1
  Wire.write(0x03); // 0x03 = PS_ON = 1
  Wire.write(0x00);
  Wire.endTransmission();
  
  Wire.beginTransmission(Addr);
  Wire.write(0x00); // 0x00 = config 1
  Wire.write(0x83); // 0x83 = PS_ON = 1 , PS_Init = 1
  Wire.write(0x00);
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x03); // 0x00 = config 2
  Wire.write(0x06); // 0x06 = PS_ST = 1
  Wire.write(0x00);
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x04); // 0x00 = config 3
  Wire.write(0x0C);
  Wire.write(0x00);
  Wire.endTransmission();

  delay(500);
}

void loop()
{
  Wire.beginTransmission(Addr);
  Wire.write(0xF8); // Data Register for proxy
  Wire.endTransmission();  // wire.end
  
  Wire.requestFrom(Addr, 2);  
  if(2 <= Wire.available()) {   // if two bytes were received
    reading = Wire.read();  // receive high byte (overwrites previous reading)
    reading = reading << 8;    // shift high byte to be high 8 bits
  } 
  // Output data to serial monitor
  Serial.print("Proximity of the device : ");
  Serial.println(reading);
 

  delay(30);
}

But also here the response from the sensor remains 0.

Thank you for your support.

Best Regards,
Toto

Sounds like a hardware wiring problem.

The sensor is a 3.3V device, connecting it directly to an Arduino UNO might fry it. As it's a surface mounted device I guess you're using a breakout board but unfortunately you failed to provide information for that board (schematics, wiring, etc.).

You don't check the return values of the I2C methods so you won't notice an error on the bus.

1 Like

Run the I2C scan program and see if you get the correct results 100% of the time, if so it is probably wire correctly, if not you at least also have a hardware problem. Post a "Schematic? of your project not a frizzy picture. Also post a link to the "Technical Information" on your sensor, links to Amazon and other third party sellers normally do not have the needed technical information.

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