← Back to IoT Blog
Connected Vehicles 28 min read

Vehicle Health Monitoring with MQTT

Build a comprehensive vehicle health monitoring system using MQTT. Track engine temperature, oil pressure, battery voltage, and receive predictive maintenance alerts.

System Overview

Prevent breakdowns and reduce maintenance costs by monitoring vehicle health in real-time. MQTT provides lightweight, reliable messaging for vehicle data.

Monitored Parameters:
  • Engine temperature
  • Oil pressure & level
  • Battery voltage & current
  • Coolant level
  • Brake pad wear
  • Tire pressure (TPMS)
  • Fuel quality & water detection

Sensor Integration

ParameterSensorNormal RangeAlert Threshold
Engine TempDS18B20/Thermocouple85-95°C>105°C
Oil Pressure5V Pressure Sensor25-65 PSI<20 PSI
Battery VoltageVoltage Divider12.5-14.5V<11.5V
Coolant LevelFloat SensorMIN-MAX

Hardware Setup

MQTT Architecture

# ESP32 MQTT Publisher
#include 

WiFiClient espClient;
PubSubClient client(espClient);

void publishHealthData() {
  StaticJsonDocument<512> doc;
  
  doc["vehicle_id"] = "VH001";
  doc["engine_temp"] = readEngineTemp();
  doc["oil_pressure"] = readOilPressure();
  doc["battery_voltage"] = readBattery();
  doc["timestamp"] = millis();
  
  char buffer[512];
  serializeJson(doc, buffer);
  
  client.publish("vehicle/health/VH001", buffer);
}

void connectMQTT() {
  client.setServer("mqtt.broker.com", 1883);
  while (!client.connected()) {
    client.connect("VehicleHealth_VH001");
  }
}

Alert System

# Node-RED Alert Flow
[
  {
    "id": "health-subscriber",
    "type": "mqtt in",
    "topic": "vehicle/health/+",
    "broker": "mqtt-broker"
  },
  {
    "id": "threshold-check",
    "type": "function",
    "func": "if (msg.payload.engine_temp > 105) {\n  msg.alert = {type: 'CRITICAL', message: 'Engine Overheating!'};\n} else if (msg.payload.oil_pressure < 20) {\n  msg.alert = {type: 'WARNING', message: 'Low Oil Pressure';\n}\nreturn msg;"
  },
  {
    "id": "notification",
    "type": "sendgrid",
    "api": "SENDGRID_API_KEY"
  }
]

Predictive Maintenance

Machine learning for failure prediction:

Installation Safety:
  • Use automotive-grade wiring
  • Add inline fuses (2A for electronics)
  • Route wires away from hot surfaces
  • Secure all connections
  • Test before road use

Next Steps

  • Add vibration analysis
  • Implement OTA firmware updates
  • Connect to service center API
  • Add driver behavior scoring