You have just finished an extraordinary project with your ESP32, your PCBs have arrived, you assembled them and … They work!
You need a case. But how to make it fit?
The answer is pretty simple if you know the tricks of the trade.
1- You have to import the dimensions of the PCB layout software into the 3d CAD program you are using.
There is no number 2.
I use KiCad for the PCB and Openscad for the 3d modeling.
In KiCad set the origin to a point that is compatible with your 3D modeling software. It can be a corner of the PCB, the center of the PCB or a corner mounting hole. In my case I used a corner mounting hole.
In the PCB software, generate a 3D model of your PCB. KiCad generates a step model. OpenScad needs a stl model. Open the step model with FreeCad and save it as a stl model, simple.
Copy the slt to the OpenScad folder where you will create the 3d model and import it into your 3d CAD software
Check the axis orientations and directions. The X and Y may be reversed or the direction of one or both may be reversed. So, x=10, y =20 in the PCB software may be x=20 and y =-10 in the 3D software.
Now give the important features names and coordinates. For example the four corner mounting holes: width, length, PCB thickness, corner1x, corner1y, corner2x, corner2y…etc. Look them up in the PCB layout or possibly in the drill file.
Now you can start designing your case and everything will fit. If you look at the image, you can see the PCB in Aqua and the mounting holes fit exactly in the standoffs.
One last trick, design your case with rounded corners. This will reduce the stress on the corner when printing and reduce the warping effect.
here is a code snippet for rounded boxes in OpenScad:
You can find the code on our GITHub page: https://github.com/Seenov/Raspberry_Pi_ADC_HAT
I hope this was useful, stay tuned for more.