3d Printed ESP32 Brick
ESP32 provides a great platform for sensors around the house but by the time you've added a USB power brick, cable and enclosure it's quite messy. I wanted a device that I could just plug in with no exposed wires and no mounting screws needed so I designed one in OpenSCAD and printed it on my Ender 3 Pro.
First I went in search of a suitable USB power brick. I wanted something small, with downward facing USB ports and some way to clip into an enclosure.
I found these that had a dimple on the side and set about creating a 3D printed case that would fit around them and clip into the dimple. One trick you need to be aware of is that most mass manufactured plastic cases like this are narrower at the enclosed end because they were designed to be injection moulded.
Here's how I create the dimples: a cut off sphere, translated and hull'd and then mirror imaged.
module half_sphere(r, h)
{
difference()
{
translate([h-r, 0, 0])
sphere(r);
cube([2*r,2*r,2*r], center=true);
}
}
module pill(r, h, length)
{
hull()
{
translate([0,-length,0])
half_sphere(r, h);
translate([0,length,0])
half_sphere(r, h);
}
}
module butterfly()
{
children();
mirror([1,0,0])
children();
}
After a couple of revisions I now have a case that works. The power brick snaps into place, a bare, male USB-A connector fits in and wires connect to an ESP32 that sits in the compartment. There's room for some sensors too but the heat from the ESP32 is a problem so I'm fixing that with an external bump for a DHT22 or BME680.
The ESP32 has enough memory for a cutdown version of my Bluetooth sniffer reporting to a Raspberry Pi and MQTT sender for sensor data.