Hello i have an odd problem with the VL6180x example test. The sensor appears to be working and it is wired correctly to my arduino uno (SCL --> A5, SDA --> A4) however when i run the example code to test lux and distances, it simply returns:
Adafruit VL6180x test!
And then stops. It should give a distance value after the lux value and then repeat. I have not edited the code at all but it seems to 'freeze' after reading the lux. Brand new to sensors so apologies if the question is very basic.
No link to the used hardware, no reference to the used library, no code posted. The IDE offers more than one library for the VL6180X, do you really expect us to check all of them and all examples there to find one that may match the output you posted?
Post the required information!
Sorry about that. Just restarted the board and it wokrs fine now. No idea why. Thanks for telling me how to post so ill know for the future.
In case someone is looking for a different solution for the intermittent lock-ups of the code for the VL6180X.
I have tried a couple of things from suggestions, which didn't make any difference (put it to 3.3V iso 5V, remove #include wire.h and arduino.h since they're declared in the library anyway, power it from a separate power source) - in this latter case it did work, but the results were nowhere near to reality.
I have also tried commenting out the "status" line - no difference, my Mega locked up and went into a WDT reset at random times between 20-500 seconds.
// uint8_t status = vl.readRangeStatus();
What did make a difference was on top of this I have also commented out the lux measurement line:
// float lux = vl.readLux(VL6180X_ALS_GAIN_5);
Now it works, no lock-ups. I also don't let it measure more often than every 2 seconds. This is all I have left from the measuring bit of the code:
unsigned long lastmeasureunlock;
if (millis()-lastmeasureunlock > 2000)
uint8_t range = vl.readRange();