Blynk adafruit VL53L0X on Wemos D1 Mini Pro

where to find this similar project code ?
I can not find any blynk project with this sensor

Easy…

You can look at my post

@xjn2k6, I see your code for esp32 not wemos D1,
and the sensor is GYVL53LOX not adafruit VL53lox,
wondering which code to be change…
I hope I can do this, I’m not a programmer for sure.

@psoro, yes it’s easy without Blynk.

this is for temp sensor which is analog (A0) sketch

void myTimerEvent(){  sensorData = analogRead(A0);  Blynk.virtualWrite(V5, sensorData);}

but what about i2c input ?

It should be something like below:



void myTimerEvent(){  distance= measure.RangeMilliMeter;  Blynk.virtualWrite(V6, distance);}

(Changing V5 to V6 for example)

Check Arduino examples once you install the Adafruit Library, I don’t have such sensor to play with…

#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

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

  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }
  
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // power 
  Serial.println(F("VL53L0X API Simple Ranging example\n\n")); 
}


void loop() {
  VL53L0X_RangingMeasurementData_t measure;
    
  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }
    
  delay(100);
}

Regards

I’ve been doing this sketch but no luck

I got counter 1, 2, 3, 4… and so on on my blynk widget
must be sending the wrong data to Virtual pin …

Can you post your code?

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "Adafruit_VL53L0X.h"
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
char auth[] = "";
char ssid[] = "";
char pass[] = "";

BlynkTimer timer;
void myTimerEvent()
{
//distance= measure.RangeMilliMeter;  
Blynk.virtualWrite(V6, millis() / 1000);
}

void setup() 
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // power 
  Serial.println(F("VL53L0X API Simple Ranging example\n\n")); 
    timer.setInterval(1000L, myTimerEvent);
}

void loop() {
  VL53L0X_RangingMeasurementData_t measure;   
  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }
    
 // delay(1000);
  Blynk.run();
 timer.run();
}

it’s a mess sketch you ever seen

It is indeed…
First of all, clean your loop… remove all stuff related your sensor from there and create a new event to put those lines and read the sensor data.

I’m not at home now to post an example.

Can you please test this code?
Remember I don’t have such sensor…

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "Adafruit_VL53L0X.h"
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
int distance =0;

char auth[] = "";
char ssid[] = "";
char pass[] = "";

BlynkTimer timer;

 void myTimerEvent()
{

Blynk.virtualWrite(V6, millis() / 1000);
}

void mydistanceEvent)()
{

VL53L0X_RangingMeasurementData_t measure;
Serial.print("Reading a measurement... ");

lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

if (measure.RangeStatus != 4) { // phase failures have incorrect data

Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
distance=measure.RangeMilliMeter;
Blynk.virtualWrite(V7, distance);

} else {
Serial.println(" out of range ");
Blynk.virtualWrite(V7, "out of range");
}
}

void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);

lox.begin()
timer.setInterval(1000L, myTimerEvent);
timer.setInterval(100L, mydistanceEvent);
}


void loop() {
Blynk.run();
timer.run();
}
 

psoro,
it works :slightly_smiling_face:, much appreciate your help

regards

1 Like