@tutorial: Homemade 3D scanner with Arduino and IR sensor

What’s up my friends, welcome back. Almost all of my DIY project have a 3D printed case of some sort of printed part. To print an object, you first need the 3D file. You have the file, you print the object. This project will do just the opposite, you have the object you get the 3D file. This machine should be able to 3D scan small objects with dimensions up to 13cm in the x and Y directions.

External Link: https://electronoobs.com/eng_arduino_tut30.php

by: ELECTRONOOBS on 2026-07-11

~3D scanner - part list

1 x Arduino NANO/UNO LINK eBay

1 x Sharp 0A51SK: LINK eBay

2 x A4988 driver: LINK eBay

2 x NEMA17 motors: LINK eBay

1 x SD module: LINK eBay

1 x 12V-2A power supply: LINK eBay

1 x screw PCB connector: LINK eBay

Female pins: LINK eBay

1 x micro-SD card: LINK eBay

1 x drilled PCB: LINK eBay

2 x 47uF cap: LINK eBay

1 x limit switch: LINK eBay

Wires LINK eBay



2 x smooth rods (200mm/8mm): LINK eBay

4 x LM8UU bearing: LINK eBay

1 x lead screw (200mm/8mm): LINK eBay

M3 screws: LINK eBay



Wire, soldering iron, solder, etc...

~PART 1 - Building the frame

Below you can find a link for the STL files for the frame. Download it and print the files using your 3D printer. I've used 2 perimeters, 20% infill, 0.4mm nozzle and 0.2mm layer height. I've printed the files using PLA material, a 0.4mm nozzle, 0.2mm layer height and 20% infill and my CREALITY CR10 printer. All files are aready oriented so you don't have to rotate them, just open them in Reperier or Cura and slice them and print!

Follow this steps and build the frame. Place the two NEMA17 motors in place on the frame base. Fix them in place with M3 screws and the printed top parts. Now, fit in place the two smooth rods. Prepare the Z-axis carrige with the linear bearings. Use zip ties and fit those in place and then, add a 8mm nut on the back.

Now place the carrige on the smooth rods, add the plastic pulley on the shaft of the motor and put the threaded rod or lead screw. Finally, add the turntable on the front motor.

The sensor will give a direct analog output according to the measured distance. Finnaly, add (or not if using no homming code) the limit switch for the Z-axis. This limit swithc is used to home the axis at the beggining of the code loop when we start the machine. The frame is ready.

~PART 2 - 3D scanner schematic

This below is what we need for the electronics part. The schematic is with an end stop limit switch. If you don't want to use it, make sure to later upload the code without limit switch. The push button is used to start the scanning process. Remember to connect Vref to 3.3V. We do that because the amximum voltage of the sensor is 2.4V. To increase precision, we use external voltage refference for the ADCs.

3D arduino scanner schematic
3D arduino scanner schematic

I've made all teh connections on a drilled PCB. We have the Arduino NANO with female pins so we could remove it. The SD card module on the side and the rest of the components. The input of 12V will eb connected to those two screw PCB connectors. I've used 0.1mm wire to make the connections. Remember to add those 47uF capacitors for the motor drivers. Connect the wires from the motors and sensor to the PCB. Make sure the rotation is in the desired direction. If not, juse reverse the motor inputs.

~PART 3 - The code

Let's see the code. Don't change anything in the code. Just the first variables at the beginning of the code acording to the parts you have used and the layer height you want. You have a code for the schematic using limit swithc for z-axis and for the manual homming. Download from below the code you want to use. If you don't have the limit switch connected, just use the other code.

Read all the comments in the code for better understanding. The code is simple. Create a loop that will make 360º rotation of the turntable. Each step we measure the distance. The X and Y increment is given by simple trigonommetry as seen below. Next, the x, y and z variable are stored to the SD card divided by a "," character. This step is important for later.

~PART 4 - Point cloud to STL

Place the object on the turntable in the middle. Connect power supply and wait for theamchine to home itself. When reached, press the scanning push button and wait. Depending on the layer height you choose and object size it will take more or less to complete. Once complete, remove the SD card.

Remove the SD card and copy the file to your PC. The file should have the next format. Three columns separated by a comma with the values of the x, y,and z coordinates. This are just points in a format of a point cloud. To obtain an STL file, we use the MESHLAB software which you could download from a link below.

Use MESHLAB

Downlad and install MESHLAB with the default install. Open meshlab and go to file, inport mesh. Here open the scanned file. In the next window select XYZ format and as a separator select the comme ','. Now the point cloud is open. We haev to give normals to the points. For that go to filter, normal curvature and orientation, compute normal for point set and in this window play with the settings. 10 was a good number. Click apply and close the window.

Now go to filter, remeshing simplification and reconstruction and here select screened poisson surface reconstruction. Play with the settings if you want and then click apply. Close the window and there we have our file.

ow, the file was scanned. The precision is not that good. For learning purposes, this project is more than enough.


So, there you have it guys. The precision could get better using a better distance sensor. Maybe a laser based one would give better precision. Also have in mind that in the code, the sensor makes 40 measurements and give the mean of those in order to increase precision. Consider using a lead screw instead of a normal threaded rod, better sensor, more measurements, add an end stop switch and improve this project however you want. Help me on PATREON.


Leave a comment

Please login in order to comment.

Comments

ADVERTISERS
ADVERTISERS
PCBWAY