Добавить ESP32-тест сопротивления USB-контактов

This commit is contained in:
AidarKC
2026-10-10 13:20:57 +03:00
parent 30541ae4af
commit e14e3dfa21
5 changed files with 328 additions and 2 deletions
@@ -4,6 +4,7 @@ Diagnostic sketches:
- `main-device/test_sketches/usb_contact_sensor_test/usb_contact_sensor_test.ino`
- `main-device/test_sketches/usb_contact_sensor_debug_test/usb_contact_sensor_debug_test.ino`
- `main-device/test_sketches/usb_contact_resistance_test/usb_contact_resistance_test.ino`
- `main-device/test_sketches/usb_contact_screen_start_stub/usb_contact_screen_start_stub.ino`
## Purpose
@@ -51,6 +52,33 @@ Sensor mode starts from the physical BOOT/user button on GPIO0, active LOW. The
While in sensor mode, pressing the BOOT/user button again restarts the device and returns normal USB mode on the next boot.
## Resistance version
The `usb_contact_resistance_test` sketch starts in normal USB mode and does not reconfigure GPIO19/20 until `Start` is tapped.
Initial screen:
- title: `USB RESISTANCE TEST`
- mode: `USB mode`
- state: `READY`
- action button: `Start`
After `Start`:
- GPIO19 / USB `D-` is configured as `OUTPUT HIGH`
- GPIO20 / USB `D+` is configured as ADC input
- the measured resistance is connected between `D-` and `D+`
- a known external 10 kΩ pulldown resistor must be connected from `D+` to `GND` for meaningful ohm calculation
- UI shows calculated resistance, raw ADC value, and measured `D+` millivolts
- very low ADC voltage is shown as `OPEN`
- near-source voltage is shown as `SHORT / LOW`
The calculation assumes a divider where the unknown resistance is the high-side resistor from 3.3 V to ADC and the known 10 kΩ resistor is the low-side resistor from ADC to GND:
`Rx = 10000 * (3300 / Vadc - 1)`
This test is intended to check whether the USB contact pair can be reused as an ADC-measured resistance input, for example before wiring a 10 kΩ potentiometer. Native USB data is unavailable while resistance mode owns GPIO19/20. Pressing `Restart to USB` calls `ESP.restart()`; after reboot normal USB mode is restored.
## GFX breath monitor version
The `usb_contact_screen_start_stub` sketch is a breath monitor firmware based on the production `Arduino_GFX` display path instead of LVGL.