Ciao a tutti, posso chiedervi un favore?
Mi potreste aiutare passo passo ad usare questo sensore del link?
Dovrebbe avere secondo i dati sul sito un sensore VL6180 ed avere questo cablaggio:
Verde TXD
Bianco RXD
Blu SCL
Giallo SDA
Nero GND
Rosso VIN
ho cercato online tutorial vari ma non ce verso di farlo funzionare, se collego verde e bianco ad Arduino UNO invertendoli quindi TXD a RXD e RXD a TXD, vedo il led IR lampeggiare, ma nessun dato, cercando online ho trovato questo sketch, che poi sarebbe lo sketch di esempio della libreria, ma sia con il sensore collegato che non collegato ottengo sempre gli stessi dati.
Mi aiutereste a capire come collegarlo ad Arduino e a creare uno sketch per usarlo?
Grazie
#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 INITALIZE"); //Initialize device and check for errors
};
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();
}