muse/book-reading-clip-lamp

A Wi‑Fi/USB‑C ESP32‑S3 reading lamp with OV5640 camera, microphone, speaker amplifier, rechargeable Li‑Po power management, six-LED boost light, USB protection/charging detection, and a clip/gooseneck enclosure with external FlexPIFA antenna.

Version
0.4.3
License
unset
Stars
0

firmware-and-assembly.txt

M9 FLAT REAR HOUSING — 09 October 2026
Uniform rear plane Z=15.5 mm, inner ceiling Z=13.5 mm; no antenna/JST bulges.
Reprint rear housing, Light cap and both indicator pipes. Supports are lengthened.
Case screws remain M2 x 16, accessed through deeper 4.4 mm diameter wells;
head tops are 5.7 mm below the back. Use a narrow screwdriver.
PCB M3 mounting, antenna tray, camera stack and electrical routing are unchanged.

M8 PCB MOUNTING — 09 October 2026
Use four M3 x 6 button-head screws (head <=5.7 mm OD x1.65 mm high) through
3.2 mm NPTH holes. Finish/tap the four enclosure posts' 2.5 mm blind pilots M3.
Install PCB screws inside the open housing before fitting the front bezel.
External case screws remain rear-entry M2 x16. Do not use longer PCB screws.
See pcb-mounting.ts and README M8 for axes and qualification requirements.

CURRENT ASSEMBLY REQUIREMENT: plug-in subassemblies, no final hand soldering.
Read plug-in-assembly.txt before the older terminal-level assembly notes below.
Bare switches/speaker/battery leads must be supplied with assembled pigtails.

M7 ANTENNA: fit Ezurio 001-0014 on removable tray before PCB installation;
see mechanical/antenna-fit-notes.txt. U.FL connects directly to U1.

LAMP CLIP HEAD — REV B FIRMWARE AND ASSEMBLY NOTES
07 October 2026

These notes apply to the custom PCB sources in this folder. Earlier wiring
instructions for separate development modules are not this board's netlist.
This is an engineering prototype design; no assembled hardware, measured battery
life, completed enclosure or working lamp firmware is supplied.

WHAT GOES WHERE
Head: 60 mm main PCB, ESP32-S3-WROOM-1U-N16R8, separate Wi-Fi antenna,
camera assembly, microphone, speaker amplifier, reading LEDs, USB-C, charger,
regulators and the Light button SW2. The radio has 16 MB flash and 8 MB octal PSRAM.
Base: protected battery, thermistor, speaker, Chat SW1 and power SW3.
The panel-mounted controls use solder lugs; no second PCB is required.
The camera is a replaceable autofocus sensor/lens on flex, plugged into J2.
There is one custom main PCB, with camera regulators and buffers on that PCB. Digital camera/audio signals stay inside the head.

CAMERA - SEEED DIRECT FLEX CONNECTION
Order Seeed SKU 114993115 OV5640 Camera for XIAO ESP32S3 Sense (With Heat Sink):
https://www.seeedstudio.com/OV5640-Camera-for-XIAO-ESP32S3-Sense-With-Heat-Sink-p-5739.html
Fit Hirose FH12-24S-0.5SH(55) at J2. Read camera-sourcing.txt and
camera-pinout.csv before inserting the camera. The Seeed pinout requires
DOVDD pin11=1.8 V; AVDD pin4 and AFVDD pin24=2.8 V; AF-GND pin23=GND.
Pin10 uses internal 1.5 V core regulation with C24/C25 decoupling only.
U9 supplies 1.8 V; R34/C32 delay the U8 2.8 V enable. U10/U11 translate
1.8 V camera data/sync to the MCU's 3.3 V. U12 supplies 1.8 V controls and
U13 translates SCCB. Do not reuse the former KLT camera or feed 3.3 V into flex.

Insert/remove only with power off; inspect contact orientation and pin1.
The 70.5 mm flex needs a gentle fold and a lens support independent of the
ribbon. Allow heat-sink and latch clearance. Scope rail order before capture,
use internal-DVDD mode, perform hardware reset, and initialize autofocus with
the Seeed examples. Begin at 10 MHz XCLK, then qualify timing and autofocus
at the actual book distance. This assembly and firmware are not yet tested.
Detailed startup delays and primary documentation are in camera-sourcing.txt.

EIGHT-WIRE GOOSENECK HARNESS
The J3 order below follows the PCB pin numbers, not a generic cable standard.

J3 pin   Head net       Base connection
1        VBAT          Protected battery pack positive
2        GND           Protected battery pack negative
3        NTC           Cell-mounted thermistor lead 1
4        GND           Dedicated thermistor return lead 2
5        SPK_P         Speaker positive
6        SPK_N         Speaker negative
J3.7     ASK_REMOTE    Chat switch SW1 lug 1; other lug to J3.2
J3.8     PWR_REMOTE    Power SW3 common 2; lug1 to J3.2; lug3 unused

Use an insulated J3.2 ground splice inside the base for both switches.
J3.8 grounded = OFF/charge; open = ON. A broken control wire defaults ON.
R35/C36 and R36/C37 filter the remote controls. Retain firmware debounce.

Start with high-flex 22–24 AWG battery wires and suitably flexible smaller
signal/speaker wires, then verify neck bore, temperature rise and voltage drop
with the real harness. Twist the speaker pair; insulate both neck exits and
provide strain relief outside the moving section. Keep the thermistor return
separate through the neck. Check insulation to the metal neck while bending it.

Both speaker wires are driven outputs of the MAX98357A. Neither goes to GND,
battery negative or the metal neck. Begin with an 8-ohm speaker rated at least
1 W and a firmware volume limit. Qualify speaker wiring/filtering for class-D
EMI using the actual neck; a short bench speaker lead is not representative.

BATTERY, TEMPERATURE AND USB POWER
Starting pack target: protected 1-cell Li-ion/LiPo, 3.7 V nominal / 4.2 V charge,
around 2000 mAh, vendor-approved for at least 0.6 A charging and 2 A continuous
discharge. Capacity is a packaging target, not a battery-life promise.
Use a cell-mounted Semitec 103AT-2 10k thermistor (B25/85=3435 K) or qualify
an electrically equivalent curve. Do not substitute a fixed resistor for the
thermistor in an assembled rechargeable product.

With this curve, the BQ24074's nominal 28k/4k temperature thresholds correspond
to roughly -0.6/+51 degrees C. Match or adjust the sensing network to the
selected pack's allowed charge temperatures; a pack limited to 45 degrees C
needs a tighter cutoff. Validate open/short sensor faults and real temperatures.

USB input starts at 100 mA. U14 detects BC1.2 chargers and U15 detects USB-C
sources advertising 1.5 A / 3 A. Either hardware permission selects the BQ24074
500 mA input mode through U17. The USB-powered U18 rail makes this independent
of the base switch and ESP32 boot. Unknown sources retain the 100 mA fallback.
GPIO21 is a third U17 input: raise it only after a USB host configures the
device and permits 500 mA. Clear it on disconnect/reset/deconfiguration.
VBUS presence alone does not authorize 500 mA. See usb-power-policy.txt.
GPIO3 now drives the charger's EN2 through net USB_SUSPEND, retaining its
10k boot pulldown. It is a strapping pin at reset and a control output after
the strap is latched; preserve the intended reset state and eFuse policy.
Charger EN2/EN1 states: 00=100 mA, 01=500 mA, 10=ILIM (about 957 mA),
11=input suspend. To enter suspend, set GPIO21 high (forcing EN1 high through
U17) before EN2/GPIO3 high. To resume, lower EN2 first, then set GPIO21
according to the host permission policy; hardware detectors also affect EN1.
Never pass through state 10 accidentally. Retain both GPIO levels during
sleep, and validate all transitions on the real USB host.
There is no USB-PD voltage negotiation. U15 supplies CC sink terminations;
do not fit the removed R1/R2. Battery power may supplement active loads.
The detector's small supply current is additional to the charger input limit;
measure total USB current, inrush, enumeration and suspend on the prototype.

SW3 disables the 3.3 V regulator for charge-only recovery of a depleted pack.
It is not a battery isolation switch: the charger and SYS-fed amplifier/LED
driver remain physically connected, with control pulldowns keeping them off.
With the processor unpowered, EN2/GPIO21 return low. Hardware detection keeps
EN1 high for a recognized charger, allowing off-state USB500 charging.
Unknown sources return to USB100. Charge-only mode does not retain USB suspend.
Whole-device suspend-current and
off-state behavior remain unverified; do not claim USB compliance yet.
GPIO43's revised VBUS detector is active-low; use USB for development logs.

Power source: https://www.ti.com/lit/ds/symlink/bq24074.pdf
Thermistor: https://www.semitec-global.com/products/thermistor_at/
Amplifier: https://www.analog.com/media/en/technical-documentation/data-sheets/max98357a-max98357b.pdf

FIRMWARE — MUSE IS AN INTEGRATION TASK
SDK inspected at commit 693cde9a884ad1edc87251b9f8944815f8de4809.
The ESP32 SDK supports ESP32-S3, pairing/Wi-Fi and push-to-talk voice notes.
Its camera abstraction accepts a board-supplied JPEG capture/release backend;
the Watcher implementation demonstrates JPEG/base64 capture. This custom
OV5640 board still needs its own board definition, DVP camera backend and
registration of the capture capability. Page-image delivery associated with
the correct question must be tested against the actual Muse account.

The upstream gadget replies are TEXT. Add a text-to-speech service at the
documented start_tts integration point and play its audio through the I2S
amplifier to deliver the requested spoken answers. Do not advertise this
PCB as providing Muse voice replies merely by flashing the stock SDK.
The SDK currently specifies ESP-IDF 6.0.1 and an SDK token for pairing.
Commercial service access/terms must be established before selling units.

Implementation order:
1. Add a no-display board definition with 16 MB flash, octal PSRAM, USB,
   buttons and the pin map in index.circuit.tsx. Bring up 3.3 V first.
2. Add espressif/esp32-camera, JPEG capture in PSRAM and OV5640 autofocus.
   Start with one frame buffer. Its optional AF helper loads sensor firmware;
   trigger focus and wait for completion before taking the page image.
3. Configure standard I2S: GPIO4=BCLK, 5=WS, 6=amp data, 7=mic data.
   Use 64 BCLK per stereo frame; the left-slot INMP441 provides 24-bit samples.
   Convert to the SDK's 16 kHz PCM16 voice input and format playback correctly.
4. Implement half-duplex Ask behavior: mute speaker, record while held, capture
   and timestamp the page, complete the question turn, then synthesize/play
   the reply. Handle stale images, cancellation, retries and memory limits.
5. Keep GPIO8 amplifier enable and GPIO9 light control low during startup.
   Test lamp brightness/exposure together to avoid glare and PWM banding.
   GPIO44 Ask is not an RTC deep-sleep wake input; GPIO2 Light can wake it.
6. Implement safe USB-current state changes, battery ADC calibration, low
   battery handling and privacy controls. Prove reconnect and interrupted
   playback on hardware. Do not include production credentials in source.

Sources:
https://github.com/facebookincubator/muse-gadget-sdk/blob/693cde9a884ad1edc87251b9f8944815f8de4809/esp32/README.md
https://github.com/facebookincubator/muse-gadget-sdk/blob/693cde9a884ad1edc87251b9f8944815f8de4809/esp32/components/camera/camera.h
https://github.com/facebookincubator/muse-gadget-sdk/blob/693cde9a884ad1edc87251b9f8944815f8de4809/esp32/components/muse/boards/watcher_camera.c
https://github.com/facebookincubator/muse-gadget-sdk/blob/693cde9a884ad1edc87251b9f8944815f8de4809/esp32/components/muse/muse_chat_session.cpp
https://github.com/espressif/esp32-camera

ASSEMBLY AND BRING-UP
Use professional SMT assembly for the QFNs and bottom-port microphone. Review
the mic's segmented solder-paste ring before ordering; keep solder, adhesive
and enclosure material out of its acoustic hole. Fit the radio antenna behind
plastic, clear of the gooseneck and copper, following Espressif antenna rules.

Inspect/clean the assembled board, check rail-to-ground resistance, and verify
the harness polarity before connecting a battery. Bring up on a current-limited
supply with camera/speaker disconnected, then add camera, low-volume audio and
LEDs in stages. Measure charging and rail transients, focus/page legibility,
microphone intelligibility, Wi-Fi range and closed-enclosure temperatures.
Measure operating and sleep current before quoting battery life.

The imported INMP441ACEZ-R7 ordering option is obsolete. Qualify a microphone
intended for new designs before volume production; another MEMS microphone is not
automatically pin/footprint compatible.
https://product.tdk.com/en/search/sw_piezo/mic/mems-mic/info?part_no=INMP441

SW2 Light assembly detail:
Use E-Switch TL3305AF160QG normally-open tactile switch. The body is
4.5 x 4.5 mm and actuator height is 3.8 mm. In controls-parts.tsx, logical
pin1 joins physical pins1+2 (lower row), and logical pin2 joins physical
pins3+4 (upper row). The official land pattern and contact pairs were reviewed;
assembler review should confirm orientation and enclosure actuator fit.
Apply firmware debounce appropriate to the physical button.
Source: https://www.e-switch.com/wp-content/uploads/2023/01/TL3305.pdf

SW1 and SW3 are panel-mounted solder-lug parts listed in the BOM and README.
Solder/insulate their harness with the battery disconnected; fit retaining nuts
to the 2 mm base lid. Check switch states with a meter before applying power.

HEAD HARNESS CONNECTOR (M6)
J3: JST B8B-XH-A(LF)(SN), JLC C157972. Cable: XHP-8 housing plus eight
SXH-001T-P0.6 crimp terminals. Pin 1 is the square PCB pad; identify housing
cavity numbering from the JST drawing, not wire colors or a reversed view.
Pass the loose leads through the gooseneck BEFORE crimping and inserting the
contacts. Disconnect battery and USB for assembly/service. Remove the rear
cover, mate the plug, provide strain relief, and check pin-by-pin continuity
and absence of battery shorts before applying power. Do not pull the wires.
The uniform rear cavity clears the mated connector. Light SW2 is at (24,-8) mm.