electronics / arduino / 3d-printing
Designing an enclosure for the LiFePO4 battery monitor
The battery monitor is assembled and has been on the bench. Alongside the electronics and firmware, I’ve started working on something to put it in.
I decided to design the enclosure from scratch. It needs to house the two stacked protoboards, leave the display and controls accessible, and provide openings for the USB port and external connections. I also need to be able to take it apart while the project is still developing.
This is my first proper attempt at a parametric CAD model. So far, I have a printed box that fits the electronics, a printed lid that is too loose, and a revised design waiting for another physical test.
Choosing FreeCAD
I wanted something I could use on Ubuntu. Fusion’s lack of official Linux support ruled it out for this project. I’ve used Tinkercad before, but I wanted to be able to change dimensions without manually rebuilding large parts of the design.
I settled on FreeCAD 1.1. It runs on Linux, is free and open source, and lets me build the enclosure around editable sketches and dimensions. There is no cloud service involved. With KiCad already handling the schematic, FreeCAD gives me somewhere to work on the mechanical side.
The attraction was being able to change my mind. The positions of the display, buttons and internal supports are still developing. I wanted a model I could adjust as those decisions changed.
The learning curve has been steeper than I expected, particularly around constraints and positioning sketches.
Start with a box that fits
The electronics measured 83.2 × 54.2 × 38.6 mm. My first mistake was treating those as the outside dimensions of the enclosure. Those measurements described what needed to fit inside; the walls needed their own space.
Allowing for 2.5 mm walls and 1 mm clearance on each side gave me an external footprint of 90.2 × 61.2 mm. The box was 43.1 mm high, with an internal height of 40.6 mm.
In FreeCAD’s Part Design workbench, I drew a constrained rectangle, used Pad to turn it into a solid, then Thickness to hollow it out. Changing the original sketch dimensions updated the features that followed it. That was the first practical benefit of building a parametric model.
I printed this basic box in PLA on the Bambu Lab P2S, open side upwards, using the 0.24 mm Standard profile in Bambu Studio. The estimated print time was 41 minutes. I left out the supports and openings because I wanted to answer one question first: would the electronics fit?
They did. The boards went in without forcing them, although the 1 mm clearance on each side left more movement than I wanted.
A removable lid, and a loose fit
I created the lid as a separate Body in the same FreeCAD document. It started as a 2.5 mm plate matching the outside of the box, with a hollow rectangular rim underneath that extends 2 mm into the enclosure.
Centring that rim took longer than I expected. The sketch was attached to the underside of the lid, and its coordinates appeared reversed relative to the original sketch. I also kept trying to position a rectangle that was already constrained to the origin. Removing that constraint let me move it and apply the dimensions I actually needed.
The first rim allowed 0.3 mm clearance per side. It fitted inside the printed box, but there wasn’t enough friction to keep the lid attached. It could slip off.
I reduced the nominal clearance to 0.1 mm per side in the revised design. Whether that will hold securely still needs a print. If it remains loose, I may try small retaining bumps rather than making the whole rim tighter.
Supporting the boards
The stacked boards need support underneath them. I added four 6 × 6 mm supports, each 16.5 mm high, sitting against the internal corners. That size lets them extend beneath the PCB while also joining the enclosure walls.
I used projected enclosure edges to position the first support. When I tried to Pad it, FreeCAD reported Wire is not closed, even though the square itself was closed. The projected reference lines were being treated as normal geometry too. Converting them to construction geometry resolved the error.
Once the first support worked, I used a Linear Pattern to repeat it in both directions. That keeps the four supports linked to the original feature, so changing their size doesn’t mean editing four separate sketches.
Tightening up the design
To reduce the sideways movement, I increased the wall thickness while keeping the outside footprint the same.
| Dimension | First box | Revised model |
|---|---|---|
| External footprint | 90.2 × 61.2 mm | 90.2 × 61.2 mm |
| Wall thickness | 2.5 mm | 3.2 mm |
| Internal footprint | 85.2 × 56.2 mm | 83.8 × 54.8 mm |
| Clearance around the boards | 1 mm per side | 0.3 mm per side |
Moving the internal walls also meant adjusting the support spacing and resizing the lid rim. The revised rim measures 83.6 × 54.6 mm on the outside, leaving the intended 0.1 mm clearance per side within the smaller opening.
The model regenerated successfully. That confirms the CAD changes worked together; it doesn’t yet tell me whether the tighter enclosure, supports and lid will fit the real assembly.
The box and lid remain separate Bodies in one .FCStd file. I’ve committed the editable project alongside the battery monitor’s other development files. For printing, I can export both Bodies to 3MF and separate them into individual objects in Bambu Studio.
What still needs testing
The basic box and first lid have been printed. The version with thicker walls, internal supports and a tighter lid is still a CAD revision awaiting a physical fit test.
After that, I need to work out how the lid will hold the boards down, then add the display and control openings. USB access, battery connections, cable routing and strain relief also need attention.
Printing the plain box early was useful. It gave me something physical to check before spending time on features whose positions might change. It also showed that my initial clearance was more generous than necessary.
FreeCAD’s constraints have taken some getting used to, but the reason for using a parametric model is becoming clearer. I’ve been able to change the walls, supports and lid without starting again. The next print needs to show whether those changes work together outside FreeCAD as well.