esp32 ai thinker mount

// ======================================================
// ESP32-CAM SYSTEM - V2.1 CHASSIS HEIGHT FIX
// ======================================================

/ [Visibility Toggles] /
show_sleeve = true;
show_front_lid = true;
show_back_lid = true;

/ [PCB & Case Dimensions] /
pcb_w = 28.6;
pcb_l = 41.0;
// Increased from 22.0 to 26.0 for internal component clearance
pcb_h = 26.0;
wall = 2.8; // Slightly thicker wall for better structural integrity
corner_r = 3.0;

/ [Hole & Mount Dimensions] /
lens_d = 14.0;
mount_hole_d = 6.5;
mount_plate_t = 5.0;
$fn = 64;

// --- Helper Modules ---

module rounded_box(w, l, h, r) {
translate([r, r, 0])
minkowski() {
cube([w - 2r, l - 2r, h/2]);
cylinder(r = r, h = h/2);
}
}

// Reduced height of the insert from 3mm to 2mm to avoid hitting internal parts
module lid_insert_solid(gap_adjustment = 0.3) {
translate([wall + (gap_adjustment/2), wall + (gap_adjustment/2), 0])
cube([pcb_w - gap_adjustment, pcb_l - gap_adjustment, 2.0]);
}

// --- Main Components ---

module cctv_sleeve() {
difference() {
rounded_box(pcb_w + (wall2), pcb_l + (wall2), pcb_h, corner_r);
translate([wall, wall, -1]) cube([pcb_w, pcb_l, pcb_h + 2]);

    // USB/Power Port - Shifted slightly to center in the new height    translate([(pcb_w + wall*2)/2 - 7, -1, (pcb_h/2) - 4.5]) cube([14, wall + 2, 9]);    // SIDE VENTILATION    translate([-1, wall + 5, 5]) cube([wall + 2, pcb_l - 10, pcb_h - 10]);    translate([pcb_w + wall, wall + 5, 5]) cube([wall + 2, pcb_l - 10, pcb_h - 10]);}

}

module cctv_front_lid() {
difference() {
union() {
rounded_box(pcb_w + (wall2), pcb_l + (wall2), wall, corner_r);
translate([0,0,wall]) lid_insert_solid(0.3);
}
// ENLARGED CAMERA HOLE
translate([(pcb_w + wall2)/2, (pcb_l + wall2)/2 + 6, -1])
cylinder(d = lens_d, h = wall + 5);

    // FLASH CUTOUT    translate([wall + 2, (pcb_l + wall*2)/2 - 17, -1])        cube([pcb_w - 4, 13, wall + 5]);}

}

module cctv_back_lid() {
full_w = pcb_w + (wall2);
full_l = pcb_l + (wall
2);

union() {    difference() {        union() {            rounded_box(full_w, full_l, wall, corner_r);            translate([0,0,wall]) lid_insert_solid(0.3);            // INTEGRATED REINFORCED MOUNTING TAB            translate([full_w/2, full_l, 0])                cylinder(d = mount_hole_d + 10, h = mount_plate_t);            translate([full_w/2 - (mount_hole_d+10)/2, full_l - 5, 0])                cube([mount_hole_d + 10, 5, mount_plate_t]);        }        // ENLARGED MOUNTING HOLE        translate([full_w/2, full_l, -1])            cylinder(d = mount_hole_d, h = mount_plate_t + 2);        // REAR VENTILATION HOLES        for(x = [wall + 4, pcb_w + wall - 8]) {            for(y = [wall + 4, (pcb_l + wall*2)/2 - 2.5, pcb_l + wall - 8]) {                translate([x, y, -1])                     cube([5, 5, wall + 5]);            }        }    }}

}

// --- Layout Logic ---

if (show_sleeve) {
color("DimGray") cctv_sleeve();
}

if (show_front_lid) {
// Offset for better visibility in preview
translate([0, 0, pcb_h + 10])
color("Silver") cctv_front_lid();
}

if (show_back_lid) {
translate([0, -(pcb_l + 25), 0])
color("LightSlateGray") cctv_back_lid();
}