Hello all,
I am trying to connect a distance sensor VL6180x to Arduino Pro Mini via I2C. Yesterday it was working without any problems, but today it refuses to work, even though I haven't changed anything. The sensor has a logic level shifter and pullup resistors onboard. I tested it with Arduino Uno and works perfectly again. However I can't get it to work with Pro Mini again. I am using the Wire library and the VL6180x library. Pins are A4-SDA, A5-SCL, VCC-VIN, GND-GND. Here is the code I am using. It is giving TIMEOUT all the time.
#include <Wire.h>
#include <VL6180X.h>
VL6180X sensor;
void setup()
{
Serial.begin(9600);
Wire.begin();
sensor.init();
sensor.configureDefault();
// Reduce range max convergence time and ALS integration
// time to 30 ms and 50 ms, respectively, to allow 10 Hz
// operation (as suggested by Table 6 ("Interleaved mode
// limits (10 Hz operation)") in the datasheet).
sensor.writeReg(VL6180X::SYSRANGE__MAX_CONVERGENCE_TIME, 30);
sensor.writeReg16Bit(VL6180X::SYSALS__INTEGRATION_PERIOD, 50);
sensor.setTimeout(500);
// stop continuous mode if already active
sensor.stopContinuous();
// in case stopContinuous() triggered a single-shot
// measurement, wait for it to complete
delay(300);
// start interleaved continuous mode with period of 100 ms
sensor.startInterleavedContinuous(100);
}
void loop()
{
Serial.print("\tRange: ");
Serial.println(sensor.readRangeContinuous());
if (sensor.timeoutOccurred()) { Serial.println(" TIMEOUT"); }
}
}
Here is my serial monitor:
Range: 255
TIMEOUT
Range: 255
TIMEOUT
Range: 255
TIMEOUT
Range: 255
TIMEOUT
Range: 255
TIMEOUT
Range: 255
.....
I suspect something is wrong with the A4 A5 pins of the Pro Mini, or a software problem within the Wire library. Any help wpuld be greatly appreciated.