82 lines
2.3 KiB
Markdown
82 lines
2.3 KiB
Markdown
# Trikke Motion Telemetry Logger
|
|
|
|
Prototype v0 firmware for a Seeed Studio XIAO ESP32-C3 with an ADXL345
|
|
accelerometer and L3G4200D gyroscope on a shared I2C bus.
|
|
|
|
This milestone does four things:
|
|
|
|
1. Detects and verifies both sensors by their identification registers.
|
|
2. Configures each sensor for 100 Hz raw acquisition.
|
|
3. Emits timestamped, sensor-native raw readings over the XIAO USB connection.
|
|
4. Maps both sensors into a shared enclosure coordinate frame for validation.
|
|
|
|
BLE transport and phone-side storage come after the wired sensor path is proven.
|
|
|
|
## Wiring
|
|
|
|
| Signal | XIAO pin | ESP32-C3 GPIO |
|
|
| --- | --- | --- |
|
|
| SDA | D4 | GPIO6 |
|
|
| SCL | D5 | GPIO7 |
|
|
| Sensor power | 3V3 | — |
|
|
| Sensor ground | GND | — |
|
|
|
|
Both breakouts share SDA, SCL, 3V3, and GND. The firmware checks both possible
|
|
7-bit I2C addresses for each device:
|
|
|
|
- ADXL345: `0x53` or `0x1D`; expected `DEVID` is `0xE5`.
|
|
- L3G4200D: `0x69` or `0x68`; expected `WHO_AM_I` is `0xD3`.
|
|
|
|
## Sensor configuration
|
|
|
|
- ADXL345: 100 Hz output rate, full-resolution mode, +/-8 g. Nominal scale is
|
|
3.9 mg/LSB.
|
|
- L3G4200D: 100 Hz output rate, 25 Hz bandwidth, +/-500 dps. Nominal scale is
|
|
17.5 mdps/LSB.
|
|
|
|
The enclosure coordinate frame is:
|
|
|
|
- +X points right in the reference photograph.
|
|
- +Y points toward the top of the enclosure.
|
|
- +Z points out of the board toward the enclosure cover.
|
|
|
|
The L3G4200D already matches that frame. The ADXL345 mapping is:
|
|
|
|
```text
|
|
enclosure X = native Y
|
|
enclosure Y = -native X
|
|
enclosure Z = native Z
|
|
```
|
|
|
|
No calibration, filtering, or sensor fusion is performed yet.
|
|
|
|
## Build and flash
|
|
|
|
ESP-IDF 6.0.2 is installed at:
|
|
|
|
```text
|
|
/Users/jay/.espressif/v6.0.2/esp-idf
|
|
```
|
|
|
|
For each new terminal:
|
|
|
|
```sh
|
|
source /Users/jay/.espressif/v6.0.2/esp-idf/export.sh
|
|
idf.py build
|
|
idf.py -p /dev/cu.usbmodem1134101 flash monitor
|
|
```
|
|
|
|
Exit the serial monitor with `Ctrl-]`.
|
|
|
|
## USB output
|
|
|
|
After startup metadata, records use CSV:
|
|
|
|
```text
|
|
sequence,timestamp_us,accel_x_raw,accel_y_raw,accel_z_raw,gyro_x_raw,gyro_y_raw,gyro_z_raw,accel_native_x_raw,accel_native_y_raw,accel_native_z_raw,gyro_native_x_raw,gyro_native_y_raw,gyro_native_z_raw
|
|
```
|
|
|
|
`timestamp_us` is the ESP32-C3 monotonic microsecond timer since boot. The axes
|
|
in the first six sample columns use the enclosure frame above. The appended native
|
|
columns are temporary diagnostics for the coordinated orientation test.
|