IoT4Car: Telemetría Vehicular OBD-II con Arduino MKR1000 – Captura y Análisis en la Nube
Componentes y Suministros
- Arduino MKR WiFi 1000 × 1
- Conversor Lógico Bidireccional SparkFun (5V↔3.3V) × 1
- Interfaz OBD-II UART SparkFun (chip STN1110) × 1
- Cable OBD-II a DB9 SparkFun × 1
Aplicaciones y Servicios
- Arduino IDE
- freeboard.io (dashboard)
- dweet.io (broker IoT ligero)
Sobre el Proyecto
Dispositivo IoT que lee parámetros del coche (RPM, velocidad, nivel combustible, temperatura refrigerante) vía OBD-II y los sube a la nube para visualización en tiempo real y análisis posterior.
Arquitectura
- Interfaz OBD-II: Puerto estándar 16 pines (obligatorio desde 1996 en EE. UU., 2001 EU). Protocolo CAN bus (desde 2008).
- Placa interpretadora SparkFun OBD-II UART: Chip STN1110 convierte protocolos OBD a UART (comandos ELM327). ¡Ojo! Salida 5V → necesita conversor lógico a 3.3V del MKR1000.
- Arduino MKR1000: WiFi integrado, ideal para IoT. Usa
Serial1(pines 13/14) para hablar con STN1110. - Nube: dweet.io recibe POSTs HTTP; freeboard.io crea dashboard con gauges.
Comandos OBD (Modo 01 – Datos en tiempo real)
010D– Velocidad vehículo (km/h)010C– RPM motor (valor ×4 en hex)012F– Nivel combustible (0-255 → %)0105– Temp. refrigerante (°C = valor - 40)
Código Principal (Extractos Clave)
// Inicialización
Serial1.begin(9600); // ¡Serial1, no Serial! (pines 13/14)
WiFi.begin(ssid, pass);
// Bucle principal: consulta cada PID, parsea respuesta, actualiza LCD, sube a dweet.io cada 10s
void getRPM() { Serial1.println("010C"); delay(200); getResponse(); vRPM = (hexToDec(rxData[6])*256 + hexToDec(rxData[9]))/4; }
void getSpeed() { Serial1.println("010D"); delay(200); getResponse(); vSpeed = hexToDec(rxData[6]) * 0.621371; } // mph
void getFuel() { Serial1.println("012F"); delay(200); getResponse(); vFuel = hexToDec(rxData[6])/255.0*100; }
void getCoolTemp() { Serial1.println("0105"); delay(200); getResponse(); vTemp = hexToDec(rxData[6]) - 40; }
// Respuesta formato: ">1 0C 09 8C\r" → datos desde índice 6
void getResponse() { ... }
// Subida HTTP a dweet.io
void httpRequest() {
client.stop();
if (client.connect("www.dweet.io", 80)) {
String data = "POST /dweet/for/mkr1000?RPM=" + String(vRPM) +
"&Speed=" + String(vSpeed) +
"&Fuel=" + String(vFuel) +
"&Temp=" + String(vTemp);
client.println(data);
client.println("Host: www.dweet.io");
client.println("Connection: close");
client.println();
}
}
Dashboard freeboard.io
Crea datasource → dweet.io thing "mkr1000" → gauges para SPEED, RPM, FUEL, TEMP.
Esquemático
Archivo Fritzing: frizling_schematics_M8kF26dafQ.fzz – Conexiones MKR1000 (Serial1) ↔ Level Shifter ↔ OBD-II UART ↔ LCD 1602 (opcional).
Conclusión
Probado en vehículo real. Futuro: PCB integrada, probar MKR GSM 1400 (cobertura móvil). ¡Cuidado al depurar conduciendo!
Proceso de manufactura
- Guía completa de matrículas de vehículos: historia, diseño y futuro
- Sistema de Frenos Antibloqueo (ABS): Seguridad en Carreteras Resbaladizas
- Sistema de Evitación de Obstáculos con IA y Arduino: Aprendizaje por Refuerzo Q-Learning
- Mando USB para juegos DIY con Arduino – Construye tu propio gamepad de alto rendimiento
- Disfraz de nube DIY: Tira LED, Arduino Nano y componentes SparkFun
- Pixie: Reloj de pulsera NeoPixel basado en Arduino – Elegante reloj LED DIY
- Distribución del Chasis: Posición del Motor y Tipos de Tracción
- El cableado del vehículo desmitificado: claves para un sistema eléctrico fiable
- Entendiendo el tren motriz: cómo impulsa su vehículo
- Entendiendo el alternador: cómo alimenta su coche y señales de fallo
- Toma de tierra del chasis (chassis ground): propósito, función e importancia