Was trying to connect a TOF050F sensor to my Arduino in order to progress on my project for Uni.
The sensor is using a VL6180 ranging chip but every library I use, every example sketch I try to upload, it doesn't work. I get the same message every time "Failed to find sensor"
I2C address that the device was found at is 0x44 (scanned I2C 7-bit address range 0x08 to 0x77)
Sketch and pinout are attached. I connected the SCL and SDA pins only to the A4 and A5 pins on the Arduino. With the example sketch below I got no result.
Really need more - people like me on a phone can’t see code , you need to use code tags to show the code .
What are those other pins connected to Vin Rx etc ? Need a drawing of what you have done .
The fact you’ve found the address suggests the device is working
#include <Wire.h>
#include <SparkFun_VL6180X.h>
/*const float GAIN_1 = 1.01; // Actual ALS Gain of 1.01
const float GAIN_1_25 = 1.28; // Actual ALS Gain of 1.28
const float GAIN_1_67 = 1.72; // Actual ALS Gain of 1.72
const float GAIN_2_5 = 2.6; // Actual ALS Gain of 2.60
const float GAIN_5 = 5.21; // Actual ALS Gain of 5.21
const float GAIN_10 = 10.32; // Actual ALS Gain of 10.32
const float GAIN_20 = 20; // Actual ALS Gain of 20
const float GAIN_40 = 40; // Actual ALS Gain of 40
*/
#define VL6180X_ADDRESS 0x29
VL6180xIdentification identification;
VL6180x sensor(VL6180X_ADDRESS);
void setup()
{
Serial.begin(115200); // Start Serial at 115200bps
Wire.begin(); // Start I2C library
delay(100); // delay .1s
sensor.getIdentification(&identification); // Retrieve manufacture info from device memory
printIdentification(&identification); // Helper function to print all the Module information
if (sensor.VL6180xInit() != 0)
{
Serial.println("Failed to initialize. Freezing..."); // Initialize device and check for errors
while (1)
;
}
sensor.VL6180xDefautSettings(); // Load default settings to get started.
delay(1000); // delay 1s
}
void loop()
{
// Get Ambient Light level and report in LUX
Serial.print("Ambient Light Level (Lux) = ");
// Input GAIN for light levels,
// GAIN_20 // Actual ALS Gain of 20
// GAIN_10 // Actual ALS Gain of 10.32
// GAIN_5 // Actual ALS Gain of 5.21
// GAIN_2_5 // Actual ALS Gain of 2.60
// GAIN_1_67 // Actual ALS Gain of 1.72
// GAIN_1_25 // Actual ALS Gain of 1.28
// GAIN_1 // Actual ALS Gain of 1.01
// GAIN_40 // Actual ALS Gain of 40
Serial.println(sensor.getAmbientLight(GAIN_1));
// Get Distance and report in mm
Serial.print("Distance measured (mm) = ");
Serial.println(sensor.getDistance());
delay(500);
};
void printIdentification(struct VL6180xIdentification *temp)
{
Serial.print("Model ID = ");
Serial.println(temp->idModel);
Serial.print("Model Rev = ");
Serial.print(temp->idModelRevMajor);
Serial.print(".");
Serial.println(temp->idModelRevMinor);
Serial.print("Module Rev = ");
Serial.print(temp->idModuleRevMajor);
Serial.print(".");
Serial.println(temp->idModuleRevMinor);
Serial.print("Manufacture Date = ");
Serial.print((temp->idDate >> 3) & 0x001F);
Serial.print("/");
Serial.print((temp->idDate >> 8) & 0x000F);
Serial.print("/1");
Serial.print((temp->idDate >> 12) & 0x000F);
Serial.print(" Phase: ");
Serial.println(temp->idDate & 0x0007);
Serial.print("Manufacture Time (s)= ");
Serial.println(temp->idTime * 2);
Serial.println();
Serial.println();
}