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 Sensor Completed
  • 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: 23 May 2020 11:58 PM Date Created
  • Views 2824 views
  • Likes 9 likes
  • Comments 4 comments
  • fightinggermsch
  • adafruit_flora
  • vl53l1x
Related
Recommended

Social Distance Alert Sensor Completed

ralphjy
ralphjy
23 May 2020

I completed the assembly and test of my Social Distance Alert Sensor (SDAS) today.  This post is to document that process and summarize the project.

 

Here are links to the previous two blogs on the SDAS:

  1. Outdoor Social Distance Alert
  2. Social Distance Alert Initial Test

 

As I mentioned in the previous post, I was having some issues getting the longer range VL53L1X microLIDAR sensor to operate correctly.  The VL53L1X is not only longer range than the VL53L0X (4 m vs 2 m), but it is also the next generation with advanced features.  It has multiple ranging modes (short, medium, long) and a programmable region of interest (ROI) which allows multiple zones in the field of view (FOV).  I thought that mis-configuration of these features might be causing my problems.  It turns out for my application the device defaults (long range, full field of view) work well.  I had problems using the Pololu library but when I switched to using the Sparkfun library that solved my wraparound issues.

 

Here is the updated code:

Flora_vl53l1X_Sparkfun.ino

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

#define PIN 8

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

int buzzer = 10;

SFEVL53L1X distanceSensor;

void setup() {
  strip.begin();
  strip.setBrightness(50);
  strip.show(); // Initialize all pixels to 'off'

  pinMode(buzzer, OUTPUT);
  digitalWrite(buzzer, HIGH);

  Wire.begin();
  
  Serial.begin(9600);

  // wait until serial port opens for native USB devices
//  while (! Serial) {
//    delay(1);
//  }
  
  Serial.println("CQRobot VL53L1X test");
  if (distanceSensor.begin() == 0) //Begin returns 0 on a good init
  {
    Serial.println("Sensor online!");
  }

}

void loop() {
  distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
  while (!distanceSensor.checkForDataReady()) {
    delay(1);
  }
  int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
  distanceSensor.clearInterrupt();
  distanceSensor.stopRanging();

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

  float distanceInches = distance * 0.0393701;
  float distanceFeet = distanceInches / 12.0;

  Serial.print("\tDistance(ft): ");
  Serial.print(distanceFeet, 2);
  Serial.println();
  
  if (distance <= 2000) 
     {
       colorWipe(strip.Color(255, 0, 0), 500);  // Red
       digitalWrite(buzzer, LOW);               // buzzer on
     } else if (distance <= 3000){
       colorWipe(strip.Color(255, 255, 0), 500);  // Yellow
       digitalWrite(buzzer, HIGH);                // buzzer off
     } else {
       Serial.println(" out of range ");
       colorWipe(strip.Color(0, 255, 0), 500); // Green
       digitalWrite(buzzer, HIGH);             // buzzer off
      }
}

// 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);
  }
}

 

The Flora has a battery input range of 3.5V to 16V so I had a wide range of choices for power.  I ended up using a AAA battery pack which conveniently included a power switch.  For the audible alert I used a DC buzzer that draws ~13mA @ 3.3V so I could drive it directly from a digital IO pin.

 

Here are the front and back views of the electronic parts:

imageimage

 

I 3D printed a case and back cover to house the components.  I ran into a couple of issues with the case.  As you can see in the above images the VL53L1X sensor is on the same side of the PCB as its connector and likewise for the Neopixel on the Flora PCB.  That meant that those components are somewhat "sunken" into the case.  In the case of the sensor I had to enlarge the window in the case in order not to interfere with the FOV which was giving me false readings.  For the Neopixel I needed to find a way to channel the light to the top of the case.  I bought a 8mm diameter plexiglass rod and cut a short 5mm segment with my Dremel.  I inserted that segment into the case just above the Neopixel.  That worked well to direct and diffuse the LED light.

 

Here are the inside and outside views of the case components: (the buzzer and plexiglass segment are already inserted)

imageimage

 

And a view of the PCBs mounted in the case:

image

 

A close up of the front of the SDAS:

image

 

And a short video of the SDAS operating:

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

 

I'm happy with the results.  The unit is reasonably compact (80mm x 50mm x 15mm not including the battery).  This is the second project that I've been able to use a TOF sensor and I'm sure that I'll do more projects with them.  I also want to try the omni-directional microwave sensors.

 

My wife says that she won't walk with me if I'm using the SDAS but I hope the granddog won't mind.  She comes back for doggy daycare after Memorial Day and I'll have to see if the buzzer bothers her.

  • Sign in to reply

Top Comments

  • neilk
    neilk over 5 years ago +1
    Very nice completed project. Ralph. I wish I could finish and package a project to that standard!! Neil
  • ntewinkel
    ntewinkel over 5 years ago in reply to neilk +1
    That is VERY nice!! well done, and agreed with Neil - great packaging! -Nico
Parents
  • neilk
    neilk over 5 years ago

    Very nice completed project. Ralph. I wish I could finish and package a project to that standard!!

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • neilk
    neilk over 5 years ago

    Very nice completed project. Ralph. I wish I could finish and package a project to that standard!!

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • ntewinkel
    ntewinkel over 5 years ago in reply to neilk

    That is VERY nice!! well done, and agreed with Neil - great packaging!

     

    -Nico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
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