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