abse/museair-usb

USB-C–powered ESP32-C3 controller board with AP63203 buck conversion, AP2112K 3.3V regulation, I²C SEN62 sensor interface, status LED, buttons, UART/I²C headers, and extensive decoupling.

Version
0.5.7
License
unset
Stars
0

scripts/render-sen62-mount.py

"""Dimensioned drawing and actual CAD-mesh assembly preview (no AI artwork)."""
from pathlib import Path
import json
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
root=Path(__file__).resolve().parent.parent;out=root/'mechanical'
s=np.load(out/'sensor-triangles.npy');c=np.load(out/'carrier-triangles.npy')
fig=plt.figure(figsize=(13,8));ax=fig.add_subplot(111,projection='3d')
ax.add_collection3d(Poly3DCollection(s,facecolor='#c6cdd1',edgecolor='none',linewidth=0))
ax.add_collection3d(Poly3DCollection(c,facecolor='#19a6b4',edgecolor='none',linewidth=0))
pcb=[[[x,y,z] for x,y in [(-23,-35),(23,-35),(23,35),(-23,35)]] for z in [0,1.6]]
ax.add_collection3d(Poly3DCollection(pcb,facecolor='#275d46',edgecolor='#163e2e',alpha=.35))
for x in [-18,18]:
 for y in [-24,19]:ax.scatter(x,y,1.6,color='#bd503c',s=28)
ax.set_xlim(-26,26);ax.set_ylim(-43,43);ax.set_zlim(-37,5);ax.set_box_aspect([52,86,42]);ax.view_init(elev=24,azim=-45)
ax.set_xlabel('PCB X (mm)');ax.set_ylabel('PCB Y (mm)');ax.set_zlabel('Z (mm)')
ax.set_title('SEN62 + insulating carrier + PCB\nOfficial sensor CAD; printed guide cradle, retained with two nylon ties',pad=20)
fig.tight_layout();fig.savefig(out/'assembly-preview.png',dpi=160);plt.close(fig)
# Dimensioned SVG uses PCB center coordinates and a separate section view.
sx=lambda x:240+x*5.7;sy=lambda y:360-y*5.7
holes=''.join(f'<circle cx="{sx(x)}" cy="{sy(y)}" r="6.84" fill="white" stroke="#c75240" stroke-width="2"/><circle cx="{sx(x)}" cy="{sy(y)}" r="15.96" fill="none" stroke="#c75240" stroke-dasharray="4 3"/>' for x in [-18,18] for y in [-24,19])
svg=f'''<svg xmlns="http://www.w3.org/2000/svg" width="1100" height="770" viewBox="0 0 1100 770"><style>text{{font-family:Arial,sans-serif;fill:#173a40}}.label{{font-size:17px}}.dim{{font-size:18px;fill:#00788b}}</style><rect width="1100" height="770" fill="#f3f8f8"/><text x="42" y="46" font-size="29" font-weight="bold">MuseAir USB v0.5 · SEN62 carrier mounting</text><text x="42" y="78" class="label">PCB TOP view. Dimensions in mm. PCB center is (0,0).</text><rect x="{sx(-22.95)}" y="{sy(26.75)}" width="{45.9*5.7}" height="{65.5*5.7}" fill="#1aa5b4" fill-opacity=".18" stroke="#009bac" stroke-dasharray="5 4"/><rect x="{sx(-23)}" y="{sy(35)}" width="{46*5.7}" height="{70*5.7}" fill="#255c48" fill-opacity=".9" rx="11"/><rect x="{sx(-12.8)}" y="{sy(21.6)}" width="{25.6*5.7}" height="{55.2*5.7}" fill="#b8c3c7" fill-opacity=".3" stroke="#a9c8ca" stroke-dasharray="6 4"/>{holes}<text x="158" y="391" style="fill:white" class="label">SEN62 center (0,−6)</text><line x1="{sx(-18)}" y1="130" x2="{sx(18)}" y2="130" stroke="#00788b"/><text x="221" y="124" class="dim">36</text><line x1="390" y1="{sy(19)}" x2="390" y2="{sy(-24)}" stroke="#00788b"/><text x="398" y="381" class="dim">43</text><text x="110" y="613" class="label">PCB 46 × 70 × 1.6</text><text x="80" y="642" class="dim">H1/H2: (±18,−24), H3/H4: (±18,+19)</text><text x="80" y="671" class="dim">4 × Ø2.4 NPTH · Ø5.6 copper exclusion</text><text x="590" y="134" font-size="24" font-weight="bold">Section through the mounting stack</text><rect x="590" y="192" width="300" height="11.2" fill="#255c48"/><rect x="608" y="203.2" width="29" height="191.1" fill="#19a6b4"/><rect x="843" y="203.2" width="29" height="191.1" fill="#19a6b4"/><rect x="650" y="231.2" width="180" height="149.1" fill="#bcc8cc" stroke="#83969b"/><rect x="590" y="394.3" width="300" height="14" fill="#19a6b4"/><text x="678" y="312" font-size="25">SEN62</text><text x="912" y="202" class="dim">1.6 PCB</text><text x="912" y="224" class="dim">4 gap</text><text x="912" y="310" class="dim">21.3 body</text><text x="912" y="390" class="dim">2 front gap</text><text x="912" y="417" class="dim">2 base</text><text x="592" y="482" class="label">Air apertures face outward, away from PCB.</text><text x="592" y="512" class="label">M2 screws go through carrier posts, never sensor.</text><text x="592" y="542" class="label">2 nylon ties at Y=−18 and −6 retain the sensor.</text><text x="592" y="572" class="label">Carrier: 45.9 × 65.5 × 29.3.</text><text x="592" y="602" class="label">Printed prototype: confirm fit and airflow.</text><text x="42" y="727" font-size="16">Official sensor STEP and example retainer used. Derived cavity clears maximum body envelope in CAD; real fit remains untested.</text><text x="42" y="751" font-size="16">The SEN62 has no screw-hole pattern. These four holes attach the matching insulating carrier.</text></svg>'''
(out/'mounting-drawing.svg').write_text(svg)
print('Saved assembly preview and dimensioned carrier mounting drawing')