Chat
BMS_SCL, BMS_SDA, and active-low BMS_ALERT_N nets. BQ76907 balancing is host-controlled and must be periodically renewed; it is not a charger.Table
| ESP32-S3 pin | Net | Function |
|---|---|---|
| GPIO4 | MOTOR_ENABLE | DRV8701 nSLEEP; starts LOW |
| GPIO5 | MOTOR_IN1 | Bridge direction input 1 |
| GPIO6 | MOTOR_IN2 | Bridge direction input 2 |
| GPIO7 | MOTOR_FAULT_N | Active-low DRV8701 fault |
| GPIO8 | MOTOR_CURRENT_MON | Raw current-monitor ADC |
| GPIO9 | BMS_SCL | BQ76907 I²C clock |
| GPIO10 | BMS_SDA | BQ76907 I²C data |
| GPIO11 | BMS_ALERT_N | Active-low BQ76907 alert |
| GPIO12/13 | GPS_TX / GPS_RX | GPS UART |
| GPIO14 | GPS_PPS | GPS pulse-per-second |
| GPIO17/18 | LIDAR_RX / LIDAR_TX | TF-Luna UART |
| GPIO19/20 | USB D− / D+ | Native USB |
| GPIO21 | USB_VBUS_SENSE | USB VBUS divider ADC |
Ini
[env:esp32-s3-mini-1-n8] platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino board_upload.flash_size = 8MB board_build.flash_size = 8MB board_build.partitions = default_8MB.csv build_flags = -D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=1 monitor_speed = 115200
Cpp
#include <Arduino.h> #include <Wire.h> static constexpr uint8_t PIN_MOTOR_ENABLE = 4; static constexpr uint8_t PIN_MOTOR_IN1 = 5; static constexpr uint8_t PIN_MOTOR_IN2 = 6; static constexpr uint8_t PIN_MOTOR_FAULT_N = 7; static constexpr uint8_t PIN_BMS_SCL = 9; static constexpr uint8_t PIN_BMS_SDA = 10; static constexpr uint8_t PIN_BMS_ALERT_N = 11; static constexpr uint32_t HARD_MAX_PULSE_MS = 500; static constexpr float MOTOR_INHIBIT_VOLTAGE_V = 6.6f; struct BmsState { bool driverImplemented = false; bool communicationValid = false; bool configurationVerified = false; bool protectionFault = true; float packVoltageV = NAN; float cell1VoltageV = NAN; float cell2VoltageV = NAN; float temperatureC = NAN; }; BmsState bms; void bridgeOff() { digitalWrite(PIN_MOTOR_IN1, LOW); digitalWrite(PIN_MOTOR_IN2, LOW); digitalWrite(PIN_MOTOR_ENABLE, LOW); } bool hardwareFaultActive() { return digitalRead(PIN_MOTOR_FAULT_N) == LOW || digitalRead(PIN_BMS_ALERT_N) == LOW; } bool initializeBq76907() { // Intentionally fail closed until the BQ76907 Technical Reference Manual // commands, data-memory addresses, CRC policy, thresholds and readback tests // are implemented. Never guess these values. bms.driverImplemented = false; bms.communicationValid = false; bms.configurationVerified = false; bms.protectionFault = true; return false; } bool refreshBq76907() { if (!bms.driverImplemented) return false; // TODO: read cell voltages, stack voltage, TS temperature, safety status, // FET status, ALERT causes and configuration checksum/readback. return false; } bool actuatorInterlockOk() { return bms.driverImplemented && bms.communicationValid && bms.configurationVerified && !bms.protectionFault && isfinite(bms.packVoltageV) && bms.packVoltageV >= MOTOR_INHIBIT_VOLTAGE_V && !hardwareFaultActive(); } bool pulseMotor(bool forward, uint32_t durationMs) { if (!actuatorInterlockOk()) return false; durationMs = constrain(durationMs, 1UL, HARD_MAX_PULSE_MS); digitalWrite(PIN_MOTOR_IN1, LOW); digitalWrite(PIN_MOTOR_IN2, LOW); digitalWrite(PIN_MOTOR_ENABLE, HIGH); delay(5); // bounded direction dead-time digitalWrite(PIN_MOTOR_IN1, forward ? HIGH : LOW); digitalWrite(PIN_MOTOR_IN2, forward ? LOW : HIGH); const uint32_t started = millis(); while (millis() - started < durationMs) { if (hardwareFaultActive() || !refreshBq76907()) { bridgeOff(); return false; } delay(1); } bridgeOff(); return true; } void setup() { pinMode(PIN_MOTOR_ENABLE, OUTPUT); pinMode(PIN_MOTOR_IN1, OUTPUT); pinMode(PIN_MOTOR_IN2, OUTPUT); bridgeOff(); pinMode(PIN_MOTOR_FAULT_N, INPUT_PULLUP); pinMode(PIN_BMS_ALERT_N, INPUT_PULLUP); Serial.begin(115200); Wire.begin(PIN_BMS_SDA, PIN_BMS_SCL, 100000); Wire.setTimeOut(50); if (!initializeBq76907()) { Serial.println("BQ76907 driver/configuration not implemented: actuator locked out."); } } void loop() { refreshBq76907(); if (hardwareFaultActive()) bridgeOff(); delay(10); }
Redesign status
Pin mapping
Required BQ76907 production configuration
PlatformIO configuration
Safe buildable scaffold
Implementation acceptance criteria