VL53L1X and ESP8266 issues

Has anyone been able to get the VL53L1X to work on an ESP device?

i am Trying to connect VL53L1X and ESP8266 and having the following output,


my code is :

#include <ComponentObject.h>
#include <RangeSensor.h>
#include <SparkFun_VL53L1X.h>
#include <vl53l1x_class.h>
#include <vl53l1_error_codes.h>


#include <Wire.h>
#include "SparkFun_VL53L1X.h"

SFEVL53L1X distanceSensor;



void setup(void)
{
Serial.begin(115200);

pinMode(0, OUTPUT);
pinMode(2, OUTPUT);
pinMode(12, OUTPUT);
pinMode(14, OUTPUT);

digitalWrite(0, HIGH);
digitalWrite(2, LOW);
digitalWrite(12, LOW);
digitalWrite(14, LOW);

Wire.begin(4,5);

if (distanceSensor.begin() == 0) //Begin returns 0 on a good init
{
Serial.println("Sensor online!");
}
}

void loop(void)
{
digitalWrite(0, HIGH);
distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
distanceSensor.stopRanging();

Serial.print("Sensor ");
Serial.print(1);
Serial.print(" Distance(mm): ");
Serial.print(distance);
Serial.print(" ");

digitalWrite(0, LOW);
delay(100);

digitalWrite(2, HIGH);
distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
distanceSensor.stopRanging();

Serial.print("Sensor ");
Serial.print(2);
Serial.print(" Distance(mm): ");
Serial.print(distance);
Serial.print(" ");

digitalWrite(2, LOW);
delay(100);

digitalWrite(12, HIGH);
distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
distanceSensor.stopRanging();

Serial.print("Sensor ");
Serial.print(3);
Serial.print(" Distance(mm): ");
Serial.print(distance);
Serial.print(" ");

digitalWrite(12, LOW);
delay(100);

digitalWrite(14, HIGH);
distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
distanceSensor.stopRanging();

Serial.print("Sensor ");
Serial.print(4);
Serial.print(" Distance(mm): ");
Serial.print(distance);
Serial.print(" ");

digitalWrite(14, LOW);
delay(100);
Serial.println();
delay(1000);
}

Hello,

Are you using our VL53L1X carrier board? What kind of ESP8266 board do you have? Could you post a picture showing all your connections?

Kevin

Yes I am using your VL53L1X, USING ESP8266 NodeMCU LUA CP2102 ESP-12F WiFi Internet Development Board Serial Wireless. IMG_7857.HEIC (788.3 KB) IMG_7830.HEIC (1.4 MB) IMG_7837.HEIC (1.2 MB)

In this picture, you have SDA connected to D1 and SCL to D2:

That seems to be reversed compared to this pinout diagram (from here), where SDA is D2 and SCL is D1:

I am not sure if that is the board you have, but I suggest checking to make sure you don’t have the I2C connections flipped.

(By the way, please upload pictures in a more common format like .jpg or .png if you can; that makes them easier to view on the forum.)

Also, is there any particular reason you are using Sparkfun’s library? We have tested our library with an ESP8266 board and confirmed that it works, and it looks like you’re already using our library with an Uno in your other thread.

Kevin

not have the pin configuration of the library example code. so these two pins are default any boards