muse/book-reading-clip-lamp

A 60‑mm ESP32‑S3 lamp-head PCB combining USB‑C battery charging/power regulation, OV5640 autofocus camera interfacing, I²S microphone and differential speaker audio, six‑LED boost-driven reading light, buttons, status indicators, and battery monitoring.

Version
0.2.5
License
unset
Stars
0

usb-power-policy.txt

SchematicSchematic preview for usb-power-policy.txt
Lamp Clip Rev B (USB hardware unchanged from Rev A) — USB and charging behavior

USB-C provides 5 V power and USB 2.0 data. Two 5.1k CC resistors identify a sink. This board has no USB-PD controller, BC1.2 charger identification, or USB-C advertised-current detection.

At reset, or while the 3.3 V regulator is off, BQ24074 EN1 and EN2 are both pulled low: USB100 input mode. Firmware may raise GPIO21 only after a USB host accepts a configuration requesting 500 mA. It must return low when unconfigured or disconnected. Merely detecting VBUS does not authorize 500 mA.

GPIO3 controls BQ24074 EN2 with a 10k reset pull-down. On USB suspend, set EN1 high before setting EN2 high; both high select suspend. On resume, lower EN2 first, then apply the authorized EN1 current policy. Avoid EN2 high / EN1 low, which selects the approximately 957 mA ILIM setting. Preserve these output levels through MCU sleep. USB100 does not satisfy USB suspend current requirements. Charge-only or reset drops the GPIOs low, so host-suspend behavior through those transitions still needs validation.

The ISET resistor programs nominal 500 mA battery charging, but the input budget supplies both system and battery. Actual charging current falls with system load, DPPM, thermal regulation and the input limit. Wall adapters without enumeration remain at USB100 on this revision. A 2000 mAh pack takes well over 20 hours from near empty at this current.

Choose charge-only on SW3 when the pack is depleted. This disables the 3.3 V regulator so the charger can recover the cell without ESP32/camera brownout cycling. The SYS-powered amplifier and LED driver remain electrically powered but are held disabled by pull-downs. The orange CHG LED remains available because it is supplied from SYS. This is a charge-only control, not complete battery isolation.

The 2N7002 circuit senses USB presence with active-low polarity. It is not a validated VBUS threshold detector. It keeps 5 V off the MCU, but MOSFET threshold spread and input capacitance can delay disconnect detection. Firmware must invert the signal and disable UART0 TX on GPIO43. Before a final product, implement appropriate VBUS thresholds and discharge timing, verify detachment within 3 ms after unplug, verify suspend-current behavior through all power states, and add CC/BC1.2 detection if faster standalone charging is required.

Primary sources:
https://www.ti.com/lit/ds/symlink/bq24074.pdf
https://docs.espressif.com/projects/esp-idf/en/v5.5/esp32s3/api-reference/peripherals/usb_device.html