LoRaWAN-Signal-Mapping/iot/Housing.scad

237 lines
5.2 KiB
OpenSCAD

////////////////
/// Settings ///
////////////////
// The thickness of the walls
wall_thickness = 2;
// The dimensions of the box on the inside
box_inside = [ 130, 140, 110 ];
screw_diameter = 3;
screw_length = 6.3;
bb_size = [ 46, 35 ];
// -------------------------------------------
corner_piece_size = screw_diameter +
(wall_thickness * 2);
box_outside = [
box_inside[0] + (wall_thickness * 2),
box_inside[1] + (wall_thickness * 2),
box_inside[2] + (wall_thickness - 0.1)
];
// -------------------------------------------
offset_arduino = [53.4+8, 40, wall_thickness];
breadboard = [ bb_size[0], bb_size[1]+24+13, 49 ];
offset_breadboard = [70, 20, wall_thickness - 0.1];
bb_mount_height = 5;
battery = [ 60, 19, 70 ];
offset_battery = [
wall_thickness + corner_piece_size + 10,
box_inside[1] - battery[1],
0
];
power_reg = [ 54, 31, 12 ];
power_reg_underneath = 9;
offset_power_reg = [
offset_arduino[0] + 10,
85,
wall_thickness
];
offset_lid = [ box_outside[0] + 25, 0, 0 ];
//offset_lid = [ 0, 0, box_outside[2] + 25 ];
// -------------------------------------------
// Misc. Utility functions
// -------------------------------------------
module screw_port() {
difference() {
color("purple") cylinder(
h = screw_length + wall_thickness,
d = screw_diameter + (wall_thickness * 2),
$fn = 25
);
// TODO: Measure screw size, as these holes might be too big. Note that they apparently end up slightly smaller anyway, due to openscad's rendering apparent - but this probably won't be enough.
color("mediumpurple") translate([0, 0, wall_thickness + 0.1]) cylinder(
h = screw_length,
d = screw_diameter,
$fn = 25
);
};
}
// Corner generation
module corner_piece() {
color("red") difference() {
cube([
corner_piece_size,
corner_piece_size,
box_inside[2]
]);
translate([
corner_piece_size / 2,
corner_piece_size / 2,
box_inside[2] - screw_length + 0.1
]) cylinder(h = screw_length, d = screw_diameter, $fn = 25);
}
};
// Box
// -------------------------------------------
difference() {
cube(box_outside);
translate([wall_thickness, wall_thickness, wall_thickness]) {
cube(box_inside);
}
}
// Mounts
// -------------------------------------------
// Arduino
// ----------------------
translate(offset_arduino) rotate([0, 0, 90]) {
screw_port(); // Top left
translate([50.8, 15.2]) screw_port();
translate([50.8, 43.1]) screw_port();
translate([-1.3, 48.2]) screw_port();
% translate([-15.3, -2, screw_length + wall_thickness]) square([68.6, 53.4]);
}
// Breadboard Mounting
// ----------------------
% translate(offset_breadboard + [wall_thickness, -13, 0]) cube(breadboard);
translate(offset_breadboard) difference() {
union() {
translate([wall_thickness*2, 0, 0]) cube([
bb_size[0] - (wall_thickness*2),
bb_size[1] + wall_thickness*2,
bb_mount_height
]);
translate([0, wall_thickness*2, 0]) cube([
bb_size[0] + wall_thickness*2,
bb_size[1] - (wall_thickness*2),
bb_mount_height
]);
}
translate([wall_thickness, wall_thickness, -1]) cube([
bb_size[0],
bb_size[1],
bb_mount_height + 2
]);
}
// Battery box
// ----------------------
// NOTE: We'll be using velcro here to allow us to remove it easily. If we can't find any, then we'll probably have to make a 'proper' mount
% translate(offset_battery) cube(battery);
// Power Regulator
// ----------------------
% translate(offset_power_reg + [0, 0, power_reg_underneath]) cube(power_reg);
translate(offset_power_reg) {
% cube([ 46, 35, bb_mount_height ]);
translate([ 0, bb_size[1], 0 ]) cube([
46,
wall_thickness,
bb_mount_height
]);
translate([ 0, -wall_thickness, 0 ]) cube([
46,
wall_thickness,
bb_mount_height
]);
translate([-wall_thickness, -wall_thickness + 16, 0]) cube([
wall_thickness,
bb_size[1] + wall_thickness*2 - 16,
bb_mount_height
]);
translate([bb_size[0], -wall_thickness, 0]) cube([
wall_thickness,
bb_size[1] + wall_thickness*2,
bb_mount_height
]);
}
// Corners
// -------------------------------------------
{
translate([
wall_thickness,
wall_thickness,
wall_thickness - 0.1
]) corner_piece();
translate([
wall_thickness + box_inside[0] - corner_piece_size,
wall_thickness,
wall_thickness - 0.1
]) corner_piece();
translate([
wall_thickness,
wall_thickness + box_inside[1] - corner_piece_size,
wall_thickness - 0.1
]) corner_piece();
translate([
wall_thickness + box_inside[0] - corner_piece_size,
wall_thickness + box_inside[1] - corner_piece_size,
wall_thickness - 0.1
]) corner_piece();
}
// Lid
// -------------------------------------------
translate(offset_lid) {
difference() {
cube([ box_outside[0], box_outside[1], wall_thickness * 1.5 ]);
translate([0, 0, -0.1]) union() {
inset = corner_piece_size / 2 + wall_thickness;
translate([
inset,
inset,
]) cylinder(h = screw_length, d = screw_diameter, $fn = 25);
translate([
box_outside[0] - inset,
inset,
]) cylinder(h = screw_length, d = screw_diameter, $fn = 25);
translate([
box_outside[0] - inset,
box_outside[1] - inset
]) cylinder(h = screw_length, d = screw_diameter, $fn = 25);
translate([
inset,
box_outside[1] - inset
]) cylinder(h = screw_length, d = screw_diameter, $fn = 25);
}
}
}