element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Fighting Germs
  • Challenges & Projects
  • Project14
  • Fighting Germs
  • More
  • Cancel
Fighting Germs
Blog Social Distance Alert Initial Test
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Fighting Germs to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 14 May 2020 2:44 AM Date Created
  • Views 1253 views
  • Likes 5 likes
  • Comments 2 comments
  • fightinggermsch
  • adafruit_flora
  • vl53l0x
  • vl53l1x
Related
Recommended

Social Distance Alert Initial Test

ralphjy
ralphjy
14 May 2020
image

Fighting Germs

Enter Your Project for a Chance to Win a Thermal Imaging Camera, Germicidal UV Lamp, and a Shopping Cart with Matching Charity Donation!

Submit an EntrySubmit an Entry  Back to homepage image
Project14 Home
Monthly Themes
Monthly Theme Poll

 

I just received my VL53L1X sensor that has a 4 meter range from CQRobot.  I bought this particular board implementation because it was the only unit that I could get quickly.  It has a larger form factor than the VL53L0X sensors that I've been using and it also has a larger shrouded connector.  I would have preferred to have gotten a board with the same implementation as the VL53L0X.  One noticeable difference in the sensor itself is that it is in a slightly larger package and has much larger transmit and receive windows.

 

The VL53L0X is on the left and the VL53L1X is on the right.

image

 

I've been playing with the VL53L0X for a while and I expected the VL53L1X to be a "drop in" replacement, i.e. run the same code with maybe an address change and more than 2X the range.  I was surprised to discover that the API for the VL53L1X seems to be quite different with multiple ranging modes.  I installed a new library and got it to "sort of" work.  I'm getting some type of "wrap around" in the measurements and can't seem to read a distance of greater than about 1.5 meters.  Guess I need to do what I should what I should have done in the first place and take a detailed look at the spec sheet.

 

In the meantime I wanted to try out the program on the Flora board so I'm temporarily using the VL53L0X until I can get the VL53L1X figured out.

 

Here is the VL53L0X mounted on the Adafruit Flora.  I've just connected the VIN, GND, SDA, and SCL pins.  I am not using the XSHUT (shutdown pin to allow programming another I2C module's address) or GPIO1 (used as an interrupt to the microcontroller).   I am going to use the onboard Neopixel LED to provide visual social distance range feedback.

 

Neopixel indication:

  • Green - safe, measured distance is out of range (greater than approx 4 meters)
  • Yellow - caution, measured distance is approaching 2 meters
  • Red - warning, measured distance is less than 2 meters

image

 

Because I am using the shorter range sensor initially I had to adjust the values for shorter range but the algorithm is the same.

 

Flora_vl53l0x.ino

#include "Adafruit_VL53L0X.h"
#include <Adafruit_NeoPixel.h>

#define PIN 8

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

void setup() {
  strip.begin();
  strip.setBrightness(50);
  strip.show(); // Initialize all pixels to 'off'
    
  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);
    if (measure.RangeMilliMeter <= 1000) 
      {
        colorWipe(strip.Color(255, 0, 0), 500);  // Red
      } else {
        colorWipe(strip.Color(255, 255, 0), 500);  // Yellow
      }
  } else {
    Serial.println(" out of range ");
    colorWipe(strip.Color(0, 255, 0), 500); // Green
  }
    
  delay(100);
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

 

Here is a short video demonstrating it working.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

I also plan to add an audible alert to complement the Red visual warning.  First I need to figure out the VL53L1X.  Then I'll need to add a battery and switch and print a case.  The Adafruit Flora has a battery connector but it does not have an integrated charger.  It has a battery input range of 3.5V to 16V.  I haven't decide yet whether to use a LiPo battery or 3 series AAA batteries.

  • Sign in to reply

Top Comments

  • ralphjy
    ralphjy over 5 years ago in reply to dubbie +2
    Tthe lights are primarily for the person approaching you. That’s why I left them bright. I think the traffic light analogy is fairly intuitive but it would be easy to explain and would hopefully keep people…
Parents
  • dubbie
    dubbie over 5 years ago

    A nice solution and I am looking forward to the packaged product. At the moment I am investigating the benefits of using LiPo batteries over 3 x AAA batteries so I will be interested in your results.

     

    Is the LED indicator for the user or strangers passing by? A passer-by might not know what the bright light means so have you thought about how to transfer the message to move away if too close?

     

    Dubbie

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ralphjy
    ralphjy over 5 years ago in reply to dubbie

    Tthe lights are primarily for the person approaching you.  That’s why I left them bright.  I think the traffic light analogy is fairly intuitive but it would be easy to explain and would hopefully keep people from being in too close proximity for too long..  I thought adding an audible alert would also help as an indicator for both myself and the other person.  I’ve found that most people try to do the right thing but don’t have a good sense of what 6 feet or 2 meters is.  I’m trying to keep the unit compact otherwise I don’t think I would use it much.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • ralphjy
    ralphjy over 5 years ago in reply to dubbie

    Tthe lights are primarily for the person approaching you.  That’s why I left them bright.  I think the traffic light analogy is fairly intuitive but it would be easy to explain and would hopefully keep people from being in too close proximity for too long..  I thought adding an audible alert would also help as an indicator for both myself and the other person.  I’ve found that most people try to do the right thing but don’t have a good sense of what 6 feet or 2 meters is.  I’m trying to keep the unit compact otherwise I don’t think I would use it much.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube