[Solved]M5Stick and VL53L1X
-
Hi all,
I'm trying VL53L1X sensor on M5Stick through grove connection
VL53L1X---------------------M5Stick
VIN-------------------------------5v grove
GRD-------------------------------grd grove
SDA--------------------------------G21 grove
SCL---------------------------------G22 groveuploading this sketch
/* 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); Wire.begin(); Wire.setClock(400000); // use 400 kHz I2C sensor.setTimeout(500); 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); } void loop() { Serial.print(sensor.read()); if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } Serial.println(); }this is the serial monitor output...
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1100 load:0x40078000,len:9220 load:0x40080400,len:6300 entry 0x400806a4 Failed to detect and initialize sensor!whats wrong??
-
M5Stick GROVE Interface SCL: GPIO13, SDA: GPIO25. Look at M5Stick doc
-
Yes, The grove pins on M5Stick are difference with M5Core.

-
-
I cant remember the exact code but you need to add
Wire1.begin();Note the 1!its something like
Wire1.begin(13, 25);
that you need to add afterWire.begin();Sorry, I lost my source so cant remember how I solved it.
-
-
Tnks a lot guys!!!!
I will try asaic....
-
/* 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); //Wire.begin(); Wire.begin(25, 13); // (SDA, SCL) grove stick //Wire.begin(21, 22); // (SDA, SCL) grove stack Wire.setClock(400000); // use 400 kHz I2C sensor.setTimeout(500); 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); } void loop() { //Serial.print(sensor.read()); //MM Serial.print(sensor.read()/10); //CM if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } Serial.println(); }it works!!!
-
@cepics said in [Solved]M5Stick and VL53L1X:
/* 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); //Wire.begin(); Wire.begin(25, 13); // (SDA, SCL) grove stick //Wire.begin(21, 22); // (SDA, SCL) grove stack Wire.setClock(400000); // use 400 kHz I2C sensor.setTimeout(500); 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); } void loop() { //Serial.print(sensor.read()); //MM Serial.print(sensor.read()/10); //CM if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } Serial.println(); }it works!!!
Glad it works and sorry for posting the pins the wrong way around.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login