Pi3B Enclosure

From HiveTool
Revision as of 11:32, 20 January 2020 by Paul (talk | contribs) (Bottom)
Jump to: navigation, search

These enclosures were designed with OpenSCAD, sliced with Repetier and printed on a Tronxy X5S.

Raspberry Pi Model 3 Enclosure

3-D printed box for Raspberry Pi and Hive Interface Board.


Printed enclosure.
Printed enclosure.



Bottom

Screenshot 20200116 065902.png


  • Estimated printing time: 2:42
  • Layer Count 124
  • Filament Needed 10567 mm.


  1. If using the camera, cut out the large round hole for the camera lens with a utility or X-Acto knife. I used nylon screws to mount the camera in case one came lose, there wouldn't be a metal screw rolling around inside. I used 4-40 threads on the camera as I had nylon 4-40 screws.
  2. Cut and remove the supports on the HDMI opening, deburr and clean up the print.
  3. Tap the Pi standoffs M2.5. If you don't have taps, a metal screw or standoff can be used to form the threads.
  4. Remove the lens from the camera (one screw) and mount the camera.
  5. Fold the flat cable as shown.
Install camera.png


OpenSCAD code

/****************************************************************************
            Raspberry Pi Model 3 Enclosure
              bottom with camera cutout
            HiveTool.net
*****************************************************************************/
width=64;
length=94;
height=23;
wall_thickness = 2;
radius=wall_thickness/2;

difference()
   {
   union()
      {
       rounded_box(width, length, height, wall_thickness);           //  create the rounded box
        
       // add some standoff s for mounting
       translate([8.5,10.25,wall_thickness]) standoff(7,6,2.3);
       //translate([29,9.5,wall_thickness]) standoff(4,6,2.2);     //Pi Zero
       translate([57.5,10.25,wall_thickness]) standoff(7,6,2.3);
       translate([8.5,68.75,wall_thickness]) standoff(7,6,2.3);
       //translate([29,67.5,wall_thickness]) standoff(4,6,2.2);     //Pi Zero
       translate([57.5,68.75,wall_thickness]) standoff(7,6,2.3);

        // add some fillets for strength and printability
       translate([2,9.25,1])  cube([4,2,8]);
       translate([59.5,9.25,1])  cube([3.5,2,8]);
       translate([2,67.75,1])  cube([5,2,8]);
       translate([59.5,67.75,1])  cube([3.5,2,8]);
           
       // Standoffs for Camera 
     translate([(width-21-14.3), (length/2 + 14.3),wall_thickness])  standoff(2,6,2.3);
     translate([(width-21-14.3), (length/2 - 14.3),wall_thickness])  standoff(2,6,2.3);
     translate([(width-21+14.3), (length/2 - 14.3),wall_thickness])  standoff(2,6,2.3);
     translate([(width-21+14.3), (length/2 +14.3),wall_thickness])  standoff(2,6,2.3);
          
          
       // add alignment pins 
       translate ([wall_thickness,wall_thickness,height]) alignment_pin();     
       translate ([wall_thickness,length - wall_thickness,height]) rotate ([0,0,-90]) alignment_pin();
       translate ([width - wall_thickness,length - wall_thickness,height]) rotate ([0,0,180]) alignment_pin();
       translate ([width - wall_thickness,wall_thickness,height]) rotate ([0,0,90]) alignment_pin();
       
       translate ([wall_thickness+.4,wall_thickness+.4,height]) sphere(1.9, center=true, $fn=36);
        translate ([wall_thickness+.4,length - wall_thickness-.4,height]) sphere(1.9, center=true, $fn=36);
       translate ([width - wall_thickness-.4,length - wall_thickness-.4,height]) sphere(1.9, center=true, $fn=36);
       translate ([width - wall_thickness-.4,wall_thickness+.4,height])  sphere(1.9, center=true, $fn=36);
   }
   
   translate ([wall_thickness,length-wall_thickness-1,8]) cube([width-2*wall_thickness,2,4]);
   translate([42.5,91,10]) cube([16.8,4,16.5]);     // Ethernet
   translate([6,88,11]) cube(40,4,15.5);          // USBs

   // Camera mount
     translate([(width-21), (length/2), .5]) 
     difference() {
            cylinder(h=10, r=15, $fn=50);
            translate([0, 0, -5]) cylinder(h=10, r=14, $fn=50);
     }
       
// holes for camera mount  
  translate([(width-21-14.3), (length/2 + 14.3), .5]) cylinder(h=10, r=1.3, $fn=50);
  translate([(width-21-14.3), (length/2 - 14.3), .5]) cylinder(h=10, r=1.3, $fn=50);
  translate([(width-21+14.3), (length/2 - 14.3), .5]) cylinder(h=10, r=1.3, $fn=50);
  translate([(width-21+14.3), (length/2 +14.3), .5]) cylinder(h=10, r=1.3, $fn=50);

   translate([63,17.5,11.8])  rotate([90,0,90])  round_cutout2 (5,5,0,0,0) ;       // micro USB
   translate ([15,length-3,height-7]) cube([28,4,8]);    // shorten the spacers between USB/Ethernet cutouts
      
   translate([63,31,17.8]) hdmi_cutout();                                                      // hdmi
   translate([61,60.5,13.5]) rotate([0,90,0]) cylinder(h=4, r=3.2, $fn=50);   // Audio
   
   translate([width/2 - 1,3,height-5.5]) latch();     // latch    
   translate([1,length-14,height-5.5]) rotate([0,0,90]) latch();     // latch
   translate([width-1,length-14,height-5.5]) rotate([0,0,-90]) latch();     // latch
  }  

/* *****************************************************
           Create a solid cube with 8 rounded edges
           but not on the top where the cover will go.
*******************************************************/
module rounded_cube(width, length, height, wall_thickness){
hull()                                // wrap a hull around 4 cylinders with rounded bottoms
   {
   radius=wall_thickness/2; 
   // place 4 spheres in the corners, with the given radius offset vertically by the radius
   translate([(wall_thickness/2), (wall_thickness/2), radius])  sphere(r=radius, $fn=50);
   translate([(wall_thickness/2), length-(wall_thickness/2),radius]) sphere(r=radius, $fn=50);
   translate([width-(wall_thickness/2), length-(wall_thickness/2), radius])  sphere(r=radius, $fn=50);
   translate([width-(wall_thickness/2), (wall_thickness/2), radius])   sphere(r=radius, $fn=50);
    
    // place 4 cylinders in the corners, with the given radius, 
    // offset vertically by the radius of the spheres
   translate([(wall_thickness/2), (wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   translate([(wall_thickness/2), (length-wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);  
   translate([(width-wall_thickness/2), (length-wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   translate([(width-wall_thickness/2), (wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   }  
}

/**************************************************************
*           Create a hollow box with rounded edges inside and out
*           but not on the top where the cover will go
*           by subtracting a rounded cubes that is 2x the wall thickness smaller 
*           and shifted by the wall thicknes from the first rounded cube.
***************************************************************/
 module rounded_box(width, length, height, wall_thickness){
    difference()                                                  // subtract two rounded cubes
       {
       rounded_cube(width, length, height, wall_thickness);
       translate([ wall_thickness, wall_thickness, wall_thickness]) 
         rounded_cube(width-(2*wall_thickness), length-(2*wall_thickness), height, wall_thickness);
     }
 }

module standoff(height,diameter,hole){
difference() 
    {
    cylinder(h = height, r = diameter/2, $fn=6);
    cylinder(h = height+1, r = hole/2, $fn=6);
    }
}

module hdmi_cutout () {
    union()
    {
     rotate([0,-90,0]) linear_extrude(height = 4, center=true) polygon(points=[[0,0],[0,5],[-7,5],[-7,2],[-5,0]]);
     rotate([0,-90,0]) linear_extrude(height = 4, center=true) polygon(points=[[0,6],[0,10],[-7,10],[-7,6]]);
     rotate([0,-90,0]) linear_extrude(height = 4, center=true)polygon(points=[[0,11],[0,16],[-5,16],[-7,14],[-7,11]]);
     }
}

module round_cutout2 (height,width,x,y,z) {
difference()
    {
    linear_extrude(height = 4, center=true)
    hull()
       {
       translate([x-width/2,0,0])
       circle(height/2, center=true, $fn=100);
       translate([x+width/2,0,0])
       circle(height/2, center=true, $fn=100);
       }
   }
}

module square_cutout (height,width,x,y,z) {
difference()
    {
    translate([x,y,z])
    rotate([90,0,0])
    linear_extrude(height = 4, center=true)
    hull()
        {
        cube(width,wall_thickness,height);
        }
    }
}

module alignment_pin() {
        rotate([0,180,-90]) {    union() { intersection(){cube(4); sphere(3, $fn=36);}  }  }
}

module latch(){
      translate([-3,-1,0]) rotate([0,90,0]) cylinder(h=6, r=1.2, $fn=36);
}


Top

RPi3 hive interface enclosure top.png


  • The top will snap on using the three latches.
  • M2.5x30mm screws can be used to further secure the lid and board.


  1. Clean up the print.
  2. Make sure the LED will fit otherwise enlarge the LED hole with a drill bit.



OpenSCAD code

/****************************************************************************
            Raspberry Pi Model 3 Enclosure
              top for hive interface board.
            HiveTool.net
*****************************************************************************/
width=64;
length=94;
height=18;
wall_thickness = 2;
radius=wall_thickness/2;
 difference()
  {
   union()
      {
       rounded_box(width, length, height, wall_thickness);           //  create the rounded box
          
     // add lip around RJ11 cutout
     translate([20, 14, 0]) cube([35,51,4]);
          
      // add some standoffs to guide the screw and hold the board.
      translate([6.5,11,0])          standoff(18,5,3.2);
      translate([55.5,11,0])        standoff(18,5,3.2);
      translate([6.5,69,0])     standoff(18,5,3.2);
      translate([55.5,69,0])   standoff(18,5,3.2);
       // add some fillets for strength and printability
      translate([0,10,1])              cube([4.5,2,17]);
      translate([57.5,10,1])        cube([5.5,2,17]);
      translate([0,68,1])        cube([4.5,2,17]);
      translate([57.5,68,1])   cube([5.5,2,17]);
          
      // add some alignment holes
          
     translate ([wall_thickness,wall_thickness,height]) alignment_hole();   
//     translate ([wall_thickness,length - wall_thickness,height]) rotate ([0,0,-90]) alignment_hole();
     translate ([width - wall_thickness,length - wall_thickness,height]) rotate ([0,0,180]) alignment_hole();
     translate ([width - wall_thickness,wall_thickness,height]) rotate ([0,0,90]) alignment_hole();

       // add some latches      
     translate([width/2 - 4,wall_thickness-.1,1]) latch();
     translate([wall_thickness-.2,length -10, 1]) rotate ([0,0,-90]) latch();
     translate([width-wall_thickness+.2,length -18, 1]) rotate ([0,0,90]) latch(); 
     
     // extend spacers between the USB conectors 
     translate([21,length - wall_thickness-4,  wall_thickness]) cube ([4,6,height+5]);
     translate([39,length - wall_thickness-4,  wall_thickness]) cube ([4,6,height+5]);
     }
  
    // add some holes for mounting
   translate([6.5,11,-1])   cylinder(h=4, r=1.6, $fn=50);
   translate([55.5,11,-1])   cylinder(h=4, r=1.6, $fn=50);
   translate([6.5,69,-1])   cylinder(h=4, r=1.6, $fn=50);
   translate([55.5,69,-1])   cylinder(h=4, r=1.6, $fn=50);      

   translate([5,85,17]) cube([16.8,10,12]);     // Ethernet
   translate([24,85,15]) cube([15.5,10,12]);     // USB-1
   translate([42,85,15]) cube([15.5,10,12]);       // USB-2
   translate ([25,10,-1]) cylinder(h=4,r=2.51, $fn=50);   //LED
   translate([21.3,15.5,-1]) cube([32.5,48.25,6]);   // RJ11 gang jacks
   translate([15,1,16])  rotate([90,0,0])  round_cutout2 (6,6,0,0,0) ;       // 12 volt power cables
     
     // holes in corners for alignment pins
    translate ([wall_thickness+.4,wall_thickness+.4,height]) sphere(2, center=true, $fn=36);           
    translate ([wall_thickness+.4,length - wall_thickness-.4,height]) sphere(2, center=true, $fn=36);
    translate ([width - wall_thickness-.4,length - wall_thickness-.4,height]) sphere(2, center=true, $fn=36);
    translate ([width - wall_thickness-.4,wall_thickness+.4,height])  sphere(2, center=true, $fn=36);
 }   
   
/* *****************************************************
           Create a solid cube with 8 rounded edges
           but not on the top where the cover will go.
*******************************************************/
module rounded_cube(width, length, height, wall_thickness){
hull()                                // wrap a hull around 4 cylinders with rounded bottoms
   {
   radius=wall_thickness/2; 
   // place 4 spheres in the corners, with the given radius offset vertically by the radius
   translate([(wall_thickness/2), (wall_thickness/2), radius])  sphere(r=radius, $fn=50);
   translate([(wall_thickness/2), length-(wall_thickness/2),radius]) sphere(r=radius, $fn=50);
   translate([width-(wall_thickness/2), length-(wall_thickness/2), radius])  sphere(r=radius, $fn=50);
   translate([width-(wall_thickness/2), (wall_thickness/2), radius])   sphere(r=radius, $fn=50);
    
    // place 4 cylinders in the corners, with the given radius, 
    // offset vertically by the radius of the spheres
   translate([(wall_thickness/2), (wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   translate([(wall_thickness/2), (length-wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);  
   translate([(width-wall_thickness/2), (length-wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   translate([(width-wall_thickness/2), (wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   }  
}

/**************************************************************
*           Create a hollow box with rounded edges inside and out
*           but not on the top where the cover will go
*           by subtracting a rounded cubes that is 2x the wall thickness smaller 
*           and shifted by the wall thicknes from the first rounded cube.
***************************************************************/
 module rounded_box(width, length, height, wall_thickness){
    difference()                                                  // subtract two rounded cubes
       {
       rounded_cube(width, length, height, wall_thickness);
       translate([ wall_thickness, wall_thickness, wall_thickness]) 
       rounded_cube(width-(2*wall_thickness), length-(2*wall_thickness), height, wall_thickness);
     }
 }

module standoff(height,diameter,hole){
difference() 
    {
    cylinder(h = height, r = diameter/2, $fn=50);
    cylinder(h = height+1, r = hole/2, $fn=50);
    }
}

module round_cutout2 (height,width,x,y,z) {
    difference()
    {
     linear_extrude(height = 4, center=true)
     hull()
         {
         translate([x-width/2,0,0])
         circle(height/2, center=true, $fn=100);
         translate([x+width/2,0,0])
         circle(height/2, center=true, $fn=100);
         }
   }
}


module square_cutout (height,width,x,y,z) {
    difference()
    {
    translate([x,y,z])
      rotate([90,0,0])
        linear_extrude(height = 4, center=true)
          hull() { cube(width,wall_thickness,height); }
    }
}

module alignment_hole() {
        rotate([0,180,-90]) {
        union() { intersection(){cube(4); sphere(3, $fn=36);}}
    }
}
   
module latch(){
      translate([0,0,0]) cube([8,2,height+6]);         // latch
      translate([2,-.25,height+4.5]) rotate([0,90,0]) cylinder(h=4, r=1, $fn=36);
}