1

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. I am using an FTDI USB to serial converter to program the Pro Mini.

#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("Ambient: ");
  Serial.print(sensor.readAmbientContinuous());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.print("\tRange: ");
  Serial.print(sensor.readRangeContinuous());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.println();
}

This is the code bit I suspect the problem originates form in the VL6180x library:

uint8_t VL6180X::readRangeContinuous()
{
  uint16_t millis_start = millis();
  while ((readReg(RESULT__INTERRUPT_STATUS_GPIO) & 0x04) == 0)
  {
    if (io_timeout > 0 && ((uint16_t)millis() - millis_start) > io_timeout)
    {
      did_timeout = true;
      return 255;
    }
  }

  uint8_t range = readReg(RESULT__RANGE_VAL);
  writeReg(SYSTEM__INTERRUPT_CLEAR, 0x01);

  return range;
}

Here is my serial monitor:

   Range: 255
 TIMEOUT
   Range: 255
 TIMEOUT
   Range: 255
 TIMEOUT
   Range: 255
 TIMEOUT
   Range: 255
 TIMEOUT
   Range: 255
.....

Any help would be greatly appreciated.

-2

The Pro Mini has a 3.3 volts regulator rated to 150mA, as you can see here https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf, it´s rated to work from 16V but by personal experience a 5V~5.1V 200mA power supply is the best option to power it without burning it, even if it burns, you can search at the internet something like

"Desoldering led and voltage regulator on Arduino Pro Mini"

Regards

  • This answer has nothing to do with the OP's issue. Also, the answer mentions a specific power supply to connect to the Pro Mini. How do you know know the OP's Pro Mini is 3.3V? Maybe it's 5V. The Op never told us his Pro Mini's operating voltage in his question. – VE7JRO Feb 8 '18 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.