Hello Nathan,
I am going to try to write down all the tests I have done to try to help you as much as I can.
Board: Arduino Uno.
Connecting the Carrier (Vin to 5V, GND to GND, SDA to A4 and SCL to A5) to a Arduino Uno and uploading the example “Continuous” everything works fine, As soon as the sketch is uploaded I open the serial monitor and measures appear.
The Arduino Uno board also has dedicated SDA and SCL ports, again connecting the carrier (Vin to 5V, GND to GND, SDA to SDA and SCL to SCL ) we get the same results, measures appear without further problem.
And just for checks, I tried the very same things connecting to the 3.3V outlet of the Arduino Uno and it worked perfectly.
Board: Arduino/Genuino 101
Connecting the Carrier (Vin to 3.3V, GND to GND, SDA to A4 and SCL to A5) to a Arduino 101and uploading the example “Continuous” when I open the serial monitor, nothing appears. Changing the SDA and SCL the dedicated SDA and SCL ports on the board does not change anything.
I have also modified slightly the “Continuous” example as below:
/*
This example shows how to take simple range measurements with the VL53L1X. The
range readings are in units of mm.
*/
#include <Wire.h>
#include <VL53L1X.h>
VL53L1X sensor;
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println("Starting the Example");
Wire.begin();
Wire.setClock(400000); // use 400 kHz I2C
sensor.setTimeout(500);
Serial.println("About to initialize sensor");
if (!sensor.init())
{
Serial.println("Failed to detect and initialize sensor!");
while (1);
}
// Use long distance mode and allow up to 50000 us (50 ms) for a measurement.
// You can change these settings to adjust the performance of the sensor, but
// the minimum timing budget is 20 ms for short distance mode and 33 ms for
// medium and long distance modes. See the VL53L1X datasheet for more
// information on range and timing limits.
sensor.setDistanceMode(VL53L1X::Long);
sensor.setMeasurementTimingBudget(50000);
// Start continuous readings at a rate of one measurement every 50 ms (the
// inter-measurement period). This period should be at least as long as the
// timing budget.
sensor.startContinuous(50);
Serial.println("End of Setup");
}
void loop()
{
Serial.println("Begining of loop");
Serial.print(sensor.read());
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
Serial.println();
Serial.println("End of loop");
}
As you can see, I have added the “while(!Serial);” line to prevent the code start executing before I open the serial monitor and several “Serial.println” with messages to see where the code stops.
With this code on the Arduino Uno and connected as I mentioned before, I get the following in the serial Monitor:
And when I upload on the Arduino 101 all i get is:
Please note that I have made these modifications only to check where the code “stops”, not saving in any moment or changing the example code by any means.
I have done one last thing, I have opened an Arduino 101 example and see there the “wire.h” file was, then I have oppened an Arduino Uno example and check its “wire.h” file, they are located in completelly different folders:
One is “C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src”
While the other is in “C:\Users\Manuel\AppData\Local\Arduino15\packages\Intel\hardware\arc32\2.0.2\libraries\Wire\src”
I have used Textpad to check if the files are different and indeed they are, this is the results of the comparison:
Comparar: (<)C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\Wire.h (2682 bytes)
con: (>)C:\Users\Manuel\AppData\Local\Arduino15\packages\Intel\hardware\arc32\2.0.2\libraries\Wire\src\Wire.h (2270 bytes)
1,20c1,19
< /*
< TwoWire.h - TWI/I2C library for Arduino & Wiring
< Copyright (c) 2006 Nicholas Zambetti. All right reserved.
<
< This library is free software; you can redistribute it and/or
< modify it under the terms of the GNU Lesser General Public
< License as published by the Free Software Foundation; either
< version 2.1 of the License, or (at your option) any later version.
<
< This library is distributed in the hope that it will be useful,
< but WITHOUT ANY WARRANTY; without even the implied warranty of
< MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
< Lesser General Public License for more details.
<
< You should have received a copy of the GNU Lesser General Public
< License along with this library; if not, write to the Free Software
< Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
<
< Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
< */
---
> /*
> * TwoWire.h - TWI/I2C library for Linux Userspace
> * Copyright (c) 2013 Parav https://github.com/meanbot.
> * All rights reserved.
> *
> * This library is free software; you can redistribute it and/or
> * modify it under the terms of the GNU Lesser General Public
> * License as published by the Free Software Foundation; either
> * version 2.1 of the License, or (at your option) any later version.
> *
> * This library is distributed in the hope that it will be useful,
> * but WITHOUT ANY WARRANTY; without even the implied warranty of
> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> * Lesser General Public License for more details.
> *
> * You should have received a copy of the GNU Lesser General Public
> * License along with this library; if not, write to the Free Software
> * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> */
25,26c24,79
< #include <inttypes.h>
< #include "Stream.h"
---
> #include "Stream.h"
> #include "variant.h"
> #include "ss_i2c_iface.h"
>
> #define BUFFER_LENGTH 32
> #define I2C_SPEED_SLOW 1
> #define I2C_SPEED_FAST 2
>
> class TwoWire : public Stream {
> public:
> TwoWire(I2C_CONTROLLER _controller_id);
> void begin(void);
> void begin(int speed);
> void setClock(long speed);
> void beginTransmission(uint8_t);
> void beginTransmission(int);
> uint8_t endTransmission(void);
> uint8_t endTransmission(uint8_t);
> uint8_t requestFrom(uint8_t, uint8_t);
> uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
> uint8_t requestFrom(int, int);
> uint8_t requestFrom(int, int, int);
> virtual size_t write(uint8_t);
> virtual size_t write(const uint8_t *, size_t);
> virtual int available(void);
> virtual int read(void);
> virtual int peek(void);
> virtual void flush(void);
>
> inline size_t write(unsigned long n) { return write((uint8_t)n); }
> inline size_t write(long n) { return write((uint8_t)n); }
> inline size_t write(unsigned int n) { return write((uint8_t)n); }
> inline size_t write(int n) { return write((uint8_t)n); }
> using Print::write;
>
> private:
> // RX Buffer
> uint8_t *rxBuffer;
> uint8_t rxBufferIndex;
> uint8_t rxBufferLength;
>
> // TX Buffer
> uint8_t txAddress;
> uint8_t *txBuffer;
> uint8_t txBufferLength;
>
> int init_status;
>
> I2C_CONTROLLER controller_id;
> };
>
> #if WIRE_INTERFACES_COUNT > 0
> extern TwoWire Wire;
> #endif
>
> #endif
28,85d81
< #define BUFFER_LENGTH 32
<
< // WIRE_HAS_END means Wire has end()
< #define WIRE_HAS_END 1
<
< class TwoWire : public Stream
< {
< private:
< static uint8_t rxBuffer[];
< static uint8_t rxBufferIndex;
< static uint8_t rxBufferLength;
<
< static uint8_t txAddress;
< static uint8_t txBuffer[];
< static uint8_t txBufferIndex;
< static uint8_t txBufferLength;
<
< static uint8_t transmitting;
< static void (*user_onRequest)(void);
< static void (*user_onReceive)(int);
< static void onRequestService(void);
< static void onReceiveService(uint8_t*, int);
< public:
< TwoWire();
< void begin();
< void begin(uint8_t);
< void begin(int);
< void end();
< void setClock(uint32_t);
< void beginTransmission(uint8_t);
< void beginTransmission(int);
< uint8_t endTransmission(void);
< uint8_t endTransmission(uint8_t);
< uint8_t requestFrom(uint8_t, uint8_t);
< uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
< uint8_t requestFrom(uint8_t, uint8_t, uint32_t, uint8_t, uint8_t);
< uint8_t requestFrom(int, int);
< uint8_t requestFrom(int, int, int);
< virtual size_t write(uint8_t);
< virtual size_t write(const uint8_t *, size_t);
< virtual int available(void);
< virtual int read(void);
< virtual int peek(void);
< virtual void flush(void);
< void onReceive( void (*)(int) );
< void onRequest( void (*)(void) );
<
< inline size_t write(unsigned long n) { return write((uint8_t)n); }
< inline size_t write(long n) { return write((uint8_t)n); }
< inline size_t write(unsigned int n) { return write((uint8_t)n); }
< inline size_t write(int n) { return write((uint8_t)n); }
< using Print::write;
< };
<
< extern TwoWire Wire;
<
< #endif
<
As you can see, I do think that the problem might be related with this.
Any help or guidance you can provide will be eagerly accepted.
Thanks, Manuel.