Why use an ordinary measuring tape when you can measure things with a laser? If there is ever an opportunity to incorporate lasers in everyday activities, we must take it. Here, Hesam Moshiri shows you how to build your own laser ranger finder using our RP2040 chip.
- Waveshare RP2040-Zero board
- Time-of-flight (ToF) distance sensor
- 2.4″ TFT display
These all talk to each other thanks to a custom PCB designed in Altium Designer 23.
Time of flight
Don’t worry, I also had to look that up. Time-of-flight (ToF) sensors are the kind you would use if you wanted an automatic tap to turn on when someone’s hand is waved in front of it, or if you wanted to teach a robot to detect obstacles.
ToF sensors work in a similar way to a bat’s sonar system. They both measure the length of time it takes for energy to travel a distance. In this instance, the sensor measures the length of time it takes laser light to travel between the sensor and the object it is pointed at and back again. You may have seen builders or estate agents using them to take absolutely perfect measurements of room sizes.
How does it work?
The RP2040-Zero communicates with the ToF sensor via I2C. The sensor measures the distance between itself and the nearest object in front of it, and relays that measurement back to the RP2040-Zero, which then throws the number up on the LCD screen. It works best with solid objects like walls, and you’ll get some light fluctuation if you try to measure soft things like clothing or plants.
The custom PCB is also equipped with a relay and a buzzer. You could code your range finder to sound the buzzer when the measurement is within certain parameters. And you could use the relay to automatically activate and turn something on or off when an object gets close to the sensor or moves away from it. That’s how the automatic taps in fancy bathrooms work.
Build your own!
There is tons more information on Hesam’s excellent project page. If you’re interested in building your own ToF sensor range finder, you’ll find full specs here, including schematics and the PCB layout. You’ll need to register for an Altium account if you want to download the source code. Scroll to the bottom of this page and you’ll find a link to do that, just above the list of references. Also, go and subscribe to Hesam’s YouTube channel. We like him.