Arduino Time of Flight Sensor Helmet

by daj42 in Circuits > Arduino

64 Views, 0 Favorites, 0 Comments

Arduino Time of Flight Sensor Helmet

IMG_20241127_215000 (1).jpg
IMG_20241127_174140856~2.jpg
IMG_20241127_190501273_HDR.jpg

To fix a long standing problem of running into things behind and in front of me, I created this Arduino-Powered helmet that uses Time of Flight sensors and LEDs to prevent me from ever being hit again*.

*note: Does not work if objects are above you, below you, to the sides of you, anywhere else outside of the narrow fields the sensors cover, and if the objects or you are moving at more than a moderate speed.

The "helmet" uses a single Arduino R3 to power two VL53L0X Time of Flight sensors and two red LEDs which when an object gets within a set distance will light up in your periphery to alert of impending danger. The Instructable walks through the process I went through to create the working prototype of my idea, as well as challenges I faced and ways you could possibly expand the project.

Supplies

IMG_20241127_195624245.jpg

Components

2x VL53L0X Time of Flight Sensors

1x Arduino R3

2x Red LEDs

2x 220ohm resistors

1x 170 pin breadboard

1x 9v battery + connector clip

10x Female-to-Male Dupont wires

Solid Single Core Tinned Copper Wire

Heat shrink tubing

7 breadboard jumper wires (can also use the above copper wire or male-to-male dupont wires)


Tools

Soldering kit

Heat gun

Wire cutter and stripper


All items listed above that does not have a link came in this ELEGOO Arduino kit, making the cost I paid for this build $8 ($16) for the set of 2 ToF sensors, of which I bought two sets but used only one set.


Helmet Materials:

Tupperware container

Hobby knife

Get Your Code

The first thing I did after receiving my sensors in the mail was setup the libraries and Arduino sketch necessary to read the inputs from the sensors and trigger the LEDs. To create this project you will need to install the ADAFRUIT_VL53L0X library into the Arudino IDE and upload the 2ToF_2LED sketch to your Arduino unit.

If you want to create the project with the same parameters as shown, two sensors and two LEDs, you can simply do the above and move past this step.

If you want to add additional LEDs you can follow the notes in the code but it is simply to duplicate the existing code that defines, sets up, and activates LEDs but changing the values to denote the new LEDs that are added.

If you want to support extra sensors it gets much trickier. My original concept involved 4 different ToF sensors mounted on each four cardinal directions. However, the Arduino R3, only has enough dynamic memory to support two sensors with the sketch I am using. I did not know this until after I had written code to support multiple sensors and then went to set it up, so I wrote hypothetical code to support 3+ sensors, but I am unsure if it works because it is untested and to run multiple sensors you need to reset and assign different i2C addresses to each sensor, so I wrote how I think that would work based on multiple similar also hypothetical sketches for a different model of the ToF sensor, the VL53L1X and the the code my 2ToF_2LED was adapted from.

The code itself is fairly straightforward, the majority of the code is defining the sensors and LEDs and resetting the sensors to assign them i2C addresses and then an "If..Else..." statement sets the assigned LED to high when a certain distance has been reached, turning on the LED and otherwise keeping it off. You can change the distance that activates by changing the value found here and even make your own additions to change how the LEDs react to the sensors inputs.

Extend Your LEDs

IMG_20241127_194403984.jpg
IMG_20241127_194455416.jpg
IMG_20241127_194643173_HDR.jpg
IMG_20241127_194732245.jpg
IMG_20241127_194850424.jpg
IMG_20241127_194911440.jpg
IMG_20241127_194925407.jpg

To make my LEDs extend far out of my headgear I needed to extend them by splicing them together with other wire. I used Solid Single Core Tinned Copper Wire, which I cut a little over a foot long, 2 each in black for negative and red for positive. I split roughly 2 inches off each wire and then made hooks on the wires and LEDs. I then twists the loops around each other until they were as tight and flat as I could get it. You can use tweezers, or your cutters if you are careful, to help twist the wire around each other, you need to be careful to avoid snapping but the LED wires are more durable than I expected. I soldered the connection between the wires and heated up a heat wrap roughly 1 size larger than the wires over the connection keeping it secure.

Wire Your Board

IMG_20241127_195014722.jpg
IMG_20241127_195228134.jpg
IMG_20241128_014142055.jpg

Next I setup the breadboard and Arduino unit. I did this before creating my enclosure for the project because much of it was touch-and-go and I was unsure how much space the circuit and Arduino would require when I had finalized it. You can interchange this step and the next if you have a specific plan for the headgear and need to wire the board specifically to accommodate it, however everything except for the LED extensions are temporary and easy to adjust.

For this project we are connecting the R3 to a small breadboard, and on this board we will have the connectors for the sensors and the LEDS and their required resistors. With the small breadboard arranged horizontally, we make connections to 5V, GND, A5, A4 in that order from left to right. Below that, with 1 row gaps for ease of access, we make connections to the sensors, plugging in the first four pins, VIN, GND, SCL, SDA in order, skipping GP, and then connecting the XSHUT pins to the 7 and 6 inputs on the Arduino, change inputs and number of hooked up sensors according to the adjustments, if any, you made in the first step.

I was taught a helpful tip during this process, that if you end up using loose wires for the sort of grouped up connection you have on the sensors and want to keep them together, you can take a large heat wrap and seal it just below the connection to keep it secure and grouped together.

Then, opposite the divide, setup your LEDS with their 220 OHM resistors and connections in blocks of 4x3. The first connector on the bottom row, black in the third photo, goes to a GND connection, the other connection in that block 4 spaces down goes to the inputs you assign in the sketch, the defaults being 8, and 9. Above that you put the resistor, first prong directly above the GND connector and second 1 space before the input connector. Above that you put the connectors for the LED, left ground connector above the second prong of the resistor and right positive connector two spaces above the input connector. Repeat for as many LEDs as you are using, substituting for a bigger board if needed.





Gearing Your Head

IMG_20241127_190610806_HDR.jpg
IMG_20241127_190501273_HDR.jpg
IMG_20241127_174140856~2.jpg

Warning: In my project due to time and budget restraints I used a plastic Tupperware container as the housing for my circuit. I used a hobby knife to cut holes into the container for the sensors and LEDs to pop out of. This ended up being by far the most dangerous part of the project, as the top half did not cut easy, and the bottom half cut too easily, pieces constantly snapping off violently. I would caution against using the container I did and if you do, urge you to work slowly and wear protective eye wear.

The design of the enclosure is simple, get a container big enough to fit the Arduino and whatever size breadboard you end up using, make openings for the the sensors and LEDs to poke out and create a way for it to attach to your head somehow. I made two small openings in the bottom of the container and threaded a lanyard through, tying it underneath my chin to secure the headpiece.

I originally was planning to create a 3D printed case and attach to a protective screened mask but due to an unexpected time crunch I ended up going with the "no extra cost" prototype design I did and it taught me a bit about the importance of prototyping as I encountered several design mistakes through this process that can be seen in the model shown in the photos. One is that the sensors can capture only a limited, fairly narrow field, and if the sensors are misaligned in any way it makes this much more apparent. This is something I likely would not have caught onto until I finished my original design if I had not made this prototype which accentuates this design flaw more than normal.

Never Bump Into Anything Again

This project was created with the intent of creating something that solves one problem, one that is manageable, while creating another. The original design was to use more sensors to give a greater accuracy and measure all directions, and more LEDs to create a more obnoxious and distracting warning sign. To fit into the budget and time concerns I ran into, I ended up swerving into a completely different aesthetic that captures the same idea in a different way. It became a more colorful, eccentric design that "functions" but is more notable for how it changes the perception others have of the wearer than the utility it provides that wearer.