@@ -94,28 +94,23 @@ void readESCTelemetry() {
9494 escTelemetryData.amps = res->bus_current / 10 .0f ;
9595 escTelemetryData.mos_temp = res->mos_temp / 10 .0f ;
9696 escTelemetryData.cap_temp = res->cap_temp / 10 .0f ;
97- escTelemetryData.mcu_temp = res->mcu_temp / 10 .0f ;
98- escTelemetryData.motor_temp = res->motor_temp / 10 .0f ;
97+ escTelemetryData.mcu_temp = res->mcu_temp / 10 .0f ;
98+ // Filter motor temp - only update if sensor is connected (valid range: -20°C to 140°C)
99+ // Disconnected sensor reads ~149°C (thermistor pulled high)
100+ float rawMotorTemp = res->motor_temp / 10 .0f ;
101+ if (rawMotorTemp > -20 .0f && rawMotorTemp <= 140 .0f ) {
102+ escTelemetryData.motor_temp = rawMotorTemp;
103+ }
104+ // else: keep previous value (sensor disconnected or invalid)
99105 escTelemetryData.eRPM = res->speed ;
100106 escTelemetryData.inPWM = res->recv_pwm / 10 .0f ;
101107 watts = escTelemetryData.amps * escTelemetryData.volts ;
102108
103- // Store error bitmasks
104- escTelemetryData.running_error = res->running_error ;
105- escTelemetryData.selfcheck_error = res->selfcheck_error ;
106-
107- // Temperature states
108- escTelemetryData.mos_state = checkTempState (escTelemetryData.mos_temp , COMP_ESC_MOS);
109- escTelemetryData.mcu_state = checkTempState (escTelemetryData.mcu_temp , COMP_ESC_MCU);
110- escTelemetryData.cap_state = checkTempState (escTelemetryData.cap_temp , COMP_ESC_CAP);
111- escTelemetryData.motor_state = checkTempState (escTelemetryData.motor_temp , COMP_MOTOR);
112- escTelemetryData.temp_sensor_error =
113- (escTelemetryData.mos_state == TEMP_INVALID) ||
114- (escTelemetryData.mcu_state == TEMP_INVALID) ||
115- (escTelemetryData.cap_state == TEMP_INVALID) ||
116- (escTelemetryData.motor_state == TEMP_INVALID);
117-
118- // Record the time of this successful communication using the local clock
109+ // Store error bitmasks
110+ escTelemetryData.running_error = res->running_error ;
111+ escTelemetryData.selfcheck_error = res->selfcheck_error ;
112+
113+ // Record the time of this successful communication using the local clock
119114 lastSuccessfulCommTimeMs = millis ();
120115 } // else: Timestamp hasn't changed, treat as stale data, don't update local timer or telemetry
121116
@@ -309,46 +304,12 @@ double mapDouble(double x, double in_min, double in_max, double out_min, double
309304 * @param telemetry ESC telemetry data structure
310305 * @return The highest temperature value among motor, MOSFET, and capacitor temps
311306 */
312- float getHighestTemp (const STR_ESC_TELEMETRY_140& telemetry) {
313- return max (telemetry.motor_temp , max (telemetry.mos_temp , telemetry.cap_temp ));
314- }
315-
316- /* *
317- * Check temperature state for a specific component
318- * @param temp Temperature value to check
319- * @param component Component type (ESC_MOS, ESC_MCU, ESC_CAP, or MOTOR)
320- * @return Temperature state (NORMAL, WARNING, CRITICAL, or INVALID)
321- */
322- TempState checkTempState (float temp, TempComponent component) {
323- // Check for invalid temperature readings
324- if (temp < -50 || temp > 200 ) {
325- return TEMP_INVALID;
326- }
327-
328- switch (component) {
329- case COMP_ESC_MOS:
330- return temp >= ESC_MOS_CRIT ? TEMP_CRITICAL :
331- temp >= ESC_MOS_WARN ? TEMP_WARNING : TEMP_NORMAL;
332-
333- case COMP_ESC_MCU:
334- return temp >= ESC_MCU_CRIT ? TEMP_CRITICAL :
335- temp >= ESC_MCU_WARN ? TEMP_WARNING : TEMP_NORMAL;
336-
337- case COMP_ESC_CAP:
338- return temp >= ESC_CAP_CRIT ? TEMP_CRITICAL :
339- temp >= ESC_CAP_WARN ? TEMP_WARNING : TEMP_NORMAL;
340-
341- case COMP_MOTOR:
342- return temp >= MOTOR_CRIT ? TEMP_CRITICAL :
343- temp >= MOTOR_WARN ? TEMP_WARNING : TEMP_NORMAL;
344-
345- default :
346- return TEMP_INVALID;
347- }
348- }
349-
350- /* *
351- * Decode running error bitmask into human-readable string
307+ float getHighestTemp (const STR_ESC_TELEMETRY_140& telemetry) {
308+ return max (telemetry.motor_temp , max (telemetry.mos_temp , telemetry.cap_temp ));
309+ }
310+
311+ /* *
312+ * Decode running error bitmask into human-readable string
352313 * @param errorCode 16-bit running error code from ESC
353314 * @return String containing decoded error messages
354315 */
0 commit comments