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
Project14 Home
Monthly Themes
Monthly Theme Poll

 

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:

 

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)

 

And a view of the PCBs mounted in the case:

 

A close up of the front of the SDAS:

 

And a short video of the SDAS operating:

 

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.