[UNIHIKER K10 And ToF]: Build a Low-Cost Depth Camera That Lets Your Camera See Distance

Project Introduction

 

Have you ever run into this awkward situation: you're building an obstacle-avoiding robot, and the regular camera can capture the wall ahead, but you have no idea how far away that wall actually is. Or you want to build a motion-activated light that turns on when someone approaches, but an ultrasonic sensor can only measure a single point, so you can't tell whether the person is coming from the left or the right. In short, a regular camera can only "see" — it can't "perceive distance." Real depth cameras (like Kinect or RealSense) cost over a thousand yuan, have complex structures, and are too high a barrier for makers.

So I thought: can I give the UNIHIKER K10 a pair of 3D eyes that can "see distance" at the lowest possible cost? The solution is actually quite simple — the UNIHIKER K10 already has a built-in camera, and by adding an 8×8 ToF matrix laser ranging sensor (SEN0628), you can simultaneously obtain the camera feed and distance data for 64 zones. Using color mapping — red for near, green for mid-range, blue for far — distance variations are displayed intuitively in the image. The total hardware cost is under 300 yuan, yet it delivers the core functionality of a depth camera.

 

 

Project Highlights

  • - RGB-D Depth Vision: The UNIHIKER K10 camera captures a real-time RGB image, while the 8×8 matrix laser ranging sensor simultaneously collects depth data from 64 zones. The two data streams are overlaid for display, giving an ordinary camera feed an intuitive sense of distance.

- Color-Mapped Distance: Near zones are displayed in red, mid-range in green, and far zones in blue, with invalid data shown in dark gray. Compared to outputting a string of numbers, this approach makes it much more intuitive to see how object distances and positions change in space.

- WiFi Remote Viewing: Once the device connects to WiFi, you can view the depth-overlaid image in real time from a phone or computer browser, save a snapshot of the camera image along with the corresponding 8×8 depth data, and export CSV files for further analysis.

Preparation

Required Hardware

HARDWARE LIST
1 UNIHIKER K10
1 Gravity: 8x8 Matrix ToF 3D Distance Sensor
1 PH2.0-4P data cable
1 USB TYPE-C data cable

Wiring

Use the 4-pin cable to connect the 8×8 matrix laser ranging sensor to the I2C interface on the UNIHIKER K10.

Mounting and Fixing

To ensure the 8×8 matrix laser ranging sensor and the UNIHIKER K10 camera face the same direction and stay fixed, this project includes a 3D-printed mounting bracket that attaches to the UNIHIKER K10. The 3D print files can be downloaded here: https://github.com/rockets-cn/unihiker-k10-8x8/tree/master/3D-Model

For installation, first mount the 3D-printed bracket onto the corresponding position on top of the UNIHIKER K10, then secure the sensor onto the bracket, and finally connect the TYPE-C cable to the corresponding port on the UNIHIKER K10.

Required Software

Visual Studio Code

Build Steps

Step 1: Download the Project Files

Click the project link: https://github.com/rockets-cn/unihiker-k10-8x8, download the project files, and extract them.

Step 2: Install PlatformIO IDE

Open VS Code, click the Extensions icon on the left (the icon with four squares), search for PlatformIO IDE, and click Install. The first installation of PlatformIO IDE will cache the toolchain, board framework, and dependent libraries, which can take a while. Once complete, the PlatformIO icon will appear on the left.

Step 3: Open the Project


Click File in the top-left corner, select Open Folder, and open the project files you just downloaded.

After opening the project, you'll see platformio.ini on the left, and "Loading Project" will appear in the bottom-right corner. Wait for the loading to finish.

Once loading is complete, click the PlatformIO icon on the left, and you'll see three core function buttons: Build, Upload, and Monitor. All subsequent compilation, uploading, and serial monitoring operations are done here.

Step 4: Configure WiFi


Enter the following command in the terminal: cp include/wifisecrets.h.example include/wifisecrets.h to copy the WiFi configuration template. Then open wifi_secrets.h and change the WiFi SSID and password to your own network.

Step 5: Compile and Upload


Click the PlatformIO icon, then click Build to compile. When the terminal shows SUCCESS, the compilation was successful. Next, click Upload to upload the program to the UNIHIKER K10.

Step 6: Web Page Display


Finally, click Monitor. When the terminal shows WIFI OK, the connection was successful, and the IP address will be displayed below.

Once the WiFi connection is successful, the IP address will also appear on the second line of the UNIHIKER K10 screen.

You can now open the IP address in a web browser to view the 8×8 depth data in real time.

Web Page Features
- Save the current frame: Stores the current 8×8 data and a camera photo on the device (ring buffer, max 50 frames, lost on power-off, photos stored in PSRAM)
- Download CSV: Exports the saved frames as a CSV file
- Clear the records: Deletes saved frames and photos
- Click a thumbnail in the saved list to view the corresponding photo in full size

Summary


Congratulations! You've just built a simple depth camera based on the UNIHIKER K10 — upgrading from an ordinary camera that only captures color and texture information to a smart vision device that can both "see objects" and "perceive distance." The 8×8 matrix laser ranging sensor collects depth data from 64 zones, which is color-mapped and overlaid onto the camera feed in real time. Combined with WiFi web-based remote viewing, frame saving, and CSV export, this system is not just a cool demo — it's a depth vision development platform you can keep building on.


If you want to keep experimenting, here are a few ideas:
- Add a "too close" alarm: When the distance in a zone drops below a set threshold, highlight it with a flashing indicator on the screen and trigger a buzzer — turning it into a simple collision warning system.
- Push data to an IoT platform: Use the UNIHIKER K10's WiFi capability to periodically upload depth data to Alibaba Cloud IoT or Bafa Cloud for remote monitoring — for example, place it at your door and check your phone anytime to see if someone is approaching.

License
All Rights
Reserved
licensBg
0