π§© Parametric QR Code Generator (OpenSCAD)
Create 3D-printable QR codes directly in OpenSCAD. Type your text/URL, pick error-correction, set size and thickness, and (optionally) add a solid background plate (βquiet zoneβ) for reliable scanning.
This project uses the excellent scadqr library by Darwin Schuppan (MIT). It renders true QR modules (squares), auto-sizes the grid for your content, and supports UTF-8 text.
π Quick Start
- INPUT_TEXT β type what you want to encode (e.g., https://example.com).
- SIZE β final QR size in mm (module size scales with it).
- CODE_EXTRUDE β thickness of the black QR squares.
- Optional: SHOW_GRID_FILL + FILL_EXTRUDE + QUIET_ZONE for a solid backing plate.
- Render, export STL, print with strong contrast (dark QR on light background), and test with a phone.
Tip: Colors here are preview-only; STL exports are colorless. Use filament swap or multi-material for two colors.
π§ Parameters
Main
- INPUT_TEXT β What the QR encodes (text/URL/anything UTF-8).
- ERROR_CORRECTION β "L" (~7%), "M" (~15%), "Q" (~25%), "H" (~30%).
Higher = more robust to damage/overhangs, but uses a denser grid.
Pattern & Rendering
- MASK β 0β7. Different QR mask patterns. Leave at 0 unless a scanner struggles; try other values.
- SHOW_GRID_FILL β true/false. Adds a flat backing plate (recommended for small QRs).
Style (Preview only)
- CODE_COLOR β color of QR modules in preview.
- FILL_COLOR β color of backing plate in preview.
Thickness
- CODE_EXTRUDE β QR module height (mm). 0.6β1.2 mm works well for FDM.
- FILL_EXTRUDE β backing plate thickness (mm) when enabled.
Dimensions
- SIZE β overall QR width/height (mm), excluding quiet zone.
- QUIET_ZONE β margin (mm) added around all sides of the QR when the fill is shown.
Effective plate size = SIZE + 2*QUIET_ZONE.
π¨οΈ Printing Tips
- Contrast is king. Dark modules on a light plate (or vice versa). Matte materials scan best.
- First-layer quality matters most. Slow down and ensure good bed adhesion.
- Module thickness (CODE_EXTRUDE):
- Single color: 0.6β1.2 mm is usually enough to be visible.
- Two colors: pause/filament swap at Z = FILL_EXTRUDE to print modules in a second color.
- Size: For typical phone scanners, 40β60 mm with "M" or "Q" correction is a sweet spot. Long URLs may need larger SIZE or lower error correction.
π§ͺ Validation
Always scan the rendered (or printed) QR with your phone before use. If scanning fails:
- Increase SIZE or CODE_EXTRUDE.
- Try higher ERROR_CORRECTION.
- Enable SHOW_GRID_FILL with a larger QUIET_ZONE (4β6 mm total is common).
- Try a different MASK value (0β7).
You can swap the CreateQR(INPUT_TEXT); call with these helpersβ outputs to encode richer data.
βοΈ Whatβs happening under the hood
- The code picks a QR version/size based on your content & error level.
- MASK selects one of 8 standard mask patterns.
- Modules are drawn as unit squares, scaled to SIZE, then extruded by CODE_EXTRUDE.
- When SHOW_GRID_FILL is true, a centered square plate (with QUIET_ZONE) is extruded below the code to improve scan reliability and make filament swaps easy.
β
Recommended Presets
- Link/URL (general use):
SIZE=50 β’ ERROR_CORRECTION="M" β’ CODE_EXTRUDE=0.8 β’ SHOW_GRID_FILL=true β’ FILL_EXTRUDE=1 β’ QUIET_ZONE=2 - Harsh handling / outdoor:
ERROR_CORRECTION="Q" or "H" β’ increase SIZE by 10β20 mm