Clippable "Fly" Sensor (Time of Flight Sensor)

by mgt16 in Circuits > Arduino

103 Views, 0 Favorites, 0 Comments

Clippable "Fly" Sensor (Time of Flight Sensor)

PXL_20230502_111603924.jpg

For my final project in this class, we were assigned to create an Arduino based prototype that extended the senses that humans aren’t capable of. This admittedly threw me for a loop: there was truly nothing for me personally that I could find that I would like to extend the sense of myself, but upon researching an idea my professor had given me, I connected the dots to a very common yet strange phenomena: the similarities of flies that we try to swat in our houses and our inability to catch them because of their flicker fusion rate and reaction time. Thus I took the time to create my project based on these feats that are unknown to the human senses and placed them on a sensor that can be programmed to for use on a bag or other wearable where you don’t have eyes in the back of your head.

Supplies

PROGRAM-BASED:

  • Arduino Uno R3 or similar (generic brands such as the Elegoo will suffice)
  • Time of Flight sensor (Arduino compatible/VL53l0x sensor; any brand, including the brand produced by Adafruit, will suffice)
  • Servo sensor (Arduino compatible/)
  • Breadboard (any size, though a larger breadboard will yield better results for beginners)
  • M-M jumper wires (any size, though length will make the space more or less compact)
  • Arduino IDE (in order to run the Arduino system)


COSMETIC BASED:

  • Cardboard (any kind will do depending on the strength of your project)
  • Heavy duty glue or paste such as superglue or hot glue gun



(MATERIALS LINK) ← Google Docs page to store your (to use go to file → make a copy )

(AMAZON LIST) ← Amazon List link to all the program based materials above with the exception of the IDE program, which can be found on the Arduino website linked here.

SOLDERING MATERIALS

PXL_20230411_143338935.jpg
PXL_20230411_143350725.jpg
PXL_20230411_143356975.jpg
PXL_20230411_143407443(1).jpg

Because of one of the sensors being unassembled, the parts will need to be soldered for breadboard construction and proof of life. For those unfamiliar, soldering is the technique of using solder (another metal typically consisting of some contents of tin and lead) to join pieces together, such as the components that will be joined today.


If your breadboard is present, this will make the connection far easier to make as the component and its pins can be placed onto the breadboard for placement.


You will start off by soldering these pieces together (for more information on soldering tips and help for beginning users, these guides attached to this step will be a massive resource).

CONSTRUCTION ON THE BREADBOARD

PXL_20230413_155342857.jpg

Before anything gets created, first it’s tested for use on the breadboard as seen below. By “prototyping the prototype”, this allows for any revisions made before the construction process.


First, connect the necessary ground (typically a black wire) and voltage wires (typically a red wire) to the breadboard and onto the Arduino. Then following the pin signifiers on the time of flight sensor to their corresponding pins on the Uno, connect the two using the male-to-male jumper wires provided in the materials list.


Now that the time of flight sensor is placed, what’s next is to attach the servo to the rest of the components. Using the same ground and voltage connection (though the colors may be different; refer to your manual for the servo), these will be applied to the breadboard as power is already flowing through the ‘power bus’ of said breadboard. 


Your end product should look something like this, as shown above. If you prefer to have the time of flight sensor on the breadboard, place it on the breadboard and connect the necessary ground and voltage power buses on the board.

PROOF OF LIFE CONCEPT

Next, we will open up the Arduino IDE and install the necessary libraries (sketch → include library → manage libraries…); you will look for the Adafruit VL53l0X library from the user of the same name, as this is the necessary programming language for this specific sensor (anything else will not allow the sensor to run properly).

After the libraries are installed, they will be used in this proof of life concept as there are examples (filed under file → examples → Adafruit_VL53l0x → vl53l0x) that can be used to test the sensor and its soldering and its connections on the breadboard.

Using both the code for the Adafruit Time of Flight sensor as well as the provided Arduino code for the servo sensor, they will be used to ‘splice’ the code together to provide feedback loops from both the time of flight and the servo, as seen below:





#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position


void setup() {
 Serial.begin(115200);
 myservo.attach(9);

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

 if (measure.RangeMilliMeter <= 500){
 for (pos = 0; pos <= 5; pos += 1) { // goes from 0 degrees to 180 degrees
   // in steps of 1 degree
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(15);                       // waits 15 ms for the servo to reach the position
 }
 for (pos = 5; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(15);                       // waits 15 ms for the servo to reach the position
 } 
 } else{ Serial.println("too far away!!!!");}
  
 delay(100);
}


Verify the code by pressing ‘verify’ on the Arduino IDE application (after selecting your Arduino Uno as the input device) and upload the sketch. Wait until the sketch compiles and uploads to the Arduino IDE and the result is as follows in this input-output feedback loop:

‘As the presence from the time of flight sensor gets closer (for example, if it goes under 500), the servo will start whirring and moving until the number becomes higher than 500.’

Now that proof of life has been established, it is now time to start constructing the shield and design of the sensors.

Downloads

DESIGNING AND SHIELDING OF THE SENSOR/ARDUINO

PXL_20230430_022249992.jpg
PXL_20230502_101642544(1).jpg
PXL_20230502_094754351.jpg
PXL_20230502_094943418.jpg

This is where the visual and aesthetical aspects of this sensor comes into play. Although you can spend the money on getting a proper case for the Arduino and Shield, there is always a better and more organic solution: using what you have at home.


If you have any leftover cardboard from objects such as shoeboxes or from packaging, you can cut out these schematics as shown below and piece them together using a glue gun or dedicated heavy duty paste.


After creating the dimensions, either cut with an exacto knife or scissors and paste together as directed. Make sure the time of flight sensor is able to poke out of the cardboard, otherwise it will not be able to work.


And now for the most fun part of this Instructable: designing the casing for the servo shield. Any design for the casing should work so long as it's able to move around the cardboard by cutting out a hole for the servo to move.

Cut along the dimensions of the design and paste like you would the previous design.

PUTTING IT ALL TOGETHER

PXL_20230502_110103450.jpg
PXL_20230502_110109846.jpg
PXL_20230502_110127922.MP.jpg

Finally, everything leading up to this step will be all put together. Using steps two and three, you will boot up the .ino on the Arduino to be exported to the board itself after uploading. After which you’ll be able to use its programming without the USB with similar powering mechanisms (such as a 9V battery).


Slide the Arduino with the time of flight sensor into the makeshift casing for it as well as placing the servo in its own designed casing and seal the final open panel of the design with glue or paste. 


Place your 9V battery onto the sockets and see the results!